Right now, I have every song for my game set to looped, but I want it to detect when a song ends and play a different song, unless the song ended because a round started. My script is as follows:
SoundsFolder = game.Workspace.Sounds
local Songs = SoundsFolder.BGM:GetChildren()
print(Songs)
local CurrentSong = Songs[math.random(1,#Songs)]
print(CurrentSong)
CurrentSong:Play()
SoundsFolder.Wind:Stop()
game.ReplicatedStorage.Status.Changed:Connect(function(newstring)
if newstring == "Start!" then
SoundsFolder.BGM:Stop()
SoundsFolder.Wind:Play()
SoundsFolder.TornadoWarning:Play()
SoundsFolder.TornadoSiren:Play()
elseif newstring == "The game has ended! Initializing map cleanup." then
CurrentSong = Songs[math.random(1,#Songs)]
SoundsFolder.BGM:Play()
SoundsFolder.Wind:Stop()
SoundsFolder.TornadoSiren:Stop()
SoundsFolder.TornadoWarning:Stop()
elseif newstring == "Waiting For More Players..." then
CurrentSong = Songs[math.random(1,#Songs)]
SoundsFolder.BGM:Play()
SoundsFolder.Wind:Stop()
SoundsFolder.TornadoSiren:Play()
SoundsFolder.TornadoWarning:Stop()
end
end)

4 comments
How could I integrate this into my current script?
study it, u may want to use the wait line and add that variable to your script so it knows when the song stops.
or use
if Music.Playing == false then Music2:Play() endin a RunService stepped loop