Hi there! I am creating a playlist sort of script that allows a player to turn the volume/music on or off. I have a loop created which plays three consecutive songs.
while true do --For now I just have it in an infinite loop
song1:Play() --Plays first song
wait(song1.TimeLength) --Waits until the song is done to go on.
song1:Stop()-- Just in case :)
song2:Play() --I think you get the point
wait(song2.TimeLength)
song2:Stop()
song3:Play()
wait(song3.TimeLength)
song3:Stop() --Loops back
end
I'm thinking that I should have a bool value that is changed when a player clicks a button (sound off or on) . I was thinking that I could somehow break the above loop when a player "turns off" the music. Since each song is almost 200 seconds the player shouldn't wait that long before the music turns off, so puttining an if statement in the loop to check the value would be defective.
Value = true --By default, music will be playing
Value.Changed:connect(function()
if Value == false then--checks if the change turned music off
break loop --This is where I'm stuck; how would I break the above loop when the value is changed?
end
if Value == true then --If the music was off then it'll go back true
loop() --Maybe if the loop was in a funtion? I'm really stumped on the whole task so I dunno XD
end
end)
Hopefully this is understandable. I hope you guys can give me some suggestions on how I could improve this task!
Thank you!

1 comment
This works very well! Thank you!