I’m writing a scripts for a concert in roblox. There is a script in a ServerScriptService, that controls all music and lights. I need a gui reset button, that will start this script from the beginning.
I have done something like this:
local button = script.Parent
local ServerScript = game:GetService("ServerScriptService")
local ScreenGui = game:GetService("StarterGui").ScreenGui
local function onButtonActivated()
for _, sound in ipairs(workspace.Sounds:GetChildren()) do
if sound:IsA("Sound") and sound.Playing then
sound.Playing = false
end
end
for _, scripts in ipairs(ServerScript.Sounds:GetChildren()) do
if scripts.Enabled then
scripts.Enabled = false
end
end
end
button.MouseButton1Click:Connect(onButtonActivated)
My code really stops the music and lights, but if I call the script again it continues playing from the place it has stopped, not from the beginnig. How to fix that?
New contributor
user573630 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.