I am making a game with levels and each level has its own music. When switching to level 2, the game does not change the music. This script is a LocalScript in StarterPlayerScripts. No error shows up in the output. Also, this is only for two levels.
wait()
local l = game.Players.LocalPlayer.leaderstats.Level.Value
while true do
wait()
if l == 1 and script.Level1.IsPlaying == false then script.Level1:Play()
else if l == 2 and script.Level2.IsPlaying == false then script.Level2:Play() script.Level1:Stop()
end
end
end

1 comment
Ohhhhhh... that makes sense, thank you!