Hi, this is the script, and it keeps on playing the first song over and over again- I've checked if it's looped and it isn't. What's wrong?
function startSong() local isStarted1 = false local isStarted2 = false local isStarted3 = false local isStarted4 = false local isStarted5 = false while true do if not isStarted1 then game.Workspace.Feeling:Play() isStarted1 = true wait(120) game.Workspace.Feeling:Stop() isStarted1 = false elseif not isStarted2 then game.Workspace.Po:play() isStarted2 = true wait(120) game.Workspace.Po:Stop() isStarted2 = false elseif not isStarted3 then game.Workspace.Demons:play() isStarted3 = true wait(120) game.Workspace.Demons:Stop() isStarted3 = false elseif not isStarted4 then game.Workspace.Trumpets:play() isStarted4 = true wait(45) game.Workspace.Trumpets:Stop() isStarted4 = false elseif not isStarted5 then game.Workspace.Survival:play() isStarted5 = true wait(100) game.Workspace.Survival:Stop() isStarted5 = false end wait(1) end end startSong()
Here you go, try this:
local lastSong=1 while wait() do repeat song=math.random(1,5) until song~= lastSong lastSong=song; if song==1 then game.Workspace.Feeling:Play() wait(120) game.Workspace.Feeling:Stop() elseif song==2 then game.Workspace.Po:play() wait(120) game.Workspace.Po:Stop() elseif song==3 then game.Workspace.Demons:play() wait(120) game.Workspace.Demons:Stop() elseif song==4 then game.Workspace.Trumpets:play() wait(45) game.Workspace.Trumpets:Stop() elseif song==5 then game.Workspace.Survival:play() wait(100) game.Workspace.Survival:Stop() end end
It's because you are setting isStarted1
to false after it plays its 120 seconds worth of audio, which then redirects it to the same conditional path (i.e. if not isStarted1 then...
)
If you want it to play one after another, cut out the lines where it sets each isStarted value to false, and paste them at the end of the loop, altogether.
Good luck; hope I could be of help! Please consider leaving an upvote!
Every time the loop runs, it sees that the first loop is false. The loop while loop will only repeat once it's finished.
Just do:
while true do Song1:Play () wait (120) Song1:Stop () Song2:Play () wait (120) Song2:Stop () end
It's because you set isStarted back to false and the condition goes back to the first song.
I suggested doing it like...
local songnumber = 1 if songnumber == 1 --Yada Yada songnumber = 2 elseif songnumber == 2 then -- Yada Yada songnumber = 1