Hi, when people join my place, the music keeps playing from my script.
Here is the script:
while true do
game.Workspace.song1name:Play()
wait(song1length)
game.Workspace.song2name:Play()
wait(song2length)
end
It is a LOCAL Script, and I've tried putting it in many places such as Workspace and StarterGUI, but everytime it keeps repeating. I've tried a normal script too.
You need to see if the sound is started, otherwise it spams the sound, try something like this:
function startSong() local isStarted1 = false local isStarted2 = false while true do if not isStarted1 then game.Workspace.song1name:Play() isStarted1 = true wait(song1length) game.Workspace.song1name:Stop() isStarted1 = false elseif not isStarted 2 then game.Workspace.song1name:play() isStarted2 = true wait(song2length) game.Workspace.song2name:Stop() isStarted2 = false end wait(1) -- Wait 1 second before relooping again, or it will crash for StackOverflow (infinite loop) end end startSong()