Hi,
I am trying to get this script (which I made a long while ago) to stop and start music, which it half does. When I press to turn off, the music stops, but then after a while music continues again?
Anyone know how to stop the music altogether?
local Clicked = false
function onClick()
Clicked = not Clicked
script.Parent.BrickColor = BrickColor.new("Really red") -- Same here
while Clicked do
script.Parent.Parent.Sound1:Play()
wait(120)
script.Parent.Parent.Sound1:Stop()
wait(.1)
script.Parent.Parent.Sound2:Play()
wait(120)
script.Parent.Parent.Sound2:Stop()
wait(.1)
script.Parent.Parent.Sound3:Play()
wait(120)
script.Parent.Parent.Sound3:Stop()
wait(.1)
script.Parent.Parent.Sound4:Play()
wait(120)
script.Parent.Parent.Sound4:Stop()
wait(.1)
script.Parent.Parent.Sound5:Play()
wait(120)
script.Parent.Parent.Sound5:Stop()
wait(.1)
script.Parent.Parent.Sound6:Play()
wait(120)
script.Parent.Parent.Sound6:Stop()
wait(.1)
script.Parent.Parent.Sound7:Play()
wait(80)
script.Parent.Parent.Sound7:Stop()
wait(.1)
end
if not Clicked then
script.Parent.BrickColor = BrickColor.new("Medium stone grey")
script.Parent.Parent.Sound1:Stop()
script.Parent.Parent.Sound2:Stop()
script.Parent.Parent.Sound3:Stop()
script.Parent.Parent.Sound4:Stop()
script.Parent.Parent.Sound5:Stop()
script.Parent.Parent.Sound6:Stop()
script.Parent.Parent.Sound7:Stop()
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

4 comments
The music is properly stopping, but the problem is that another music will start because of Lines 7-34. Even if you stop music, the script will keep going causing the other musics to eventually play.
So you are saying to stop the script from operating altogether? How would I go about this?
You don't have to stop it all together, but make some sort of identifier that checks the Clicked value each time so that when you click the brick again, the next sound wont play.
Just disable the script, ez.