So i have a music that plays in during a battle. In the first battle it works, but when the second battle happens, the music doesn't play. I noticed that when the second battle is happening, IsPlaying in the battle music is true. What happens? It works correctly. When the battle music has to stop, the script stops it. And when it plays, it plays. But for some reason when it plays in the second time, the sound doesn't play, but the script prints that the battle music played and IsPlaying is set to true.
local LevelMan = game.Workspace:WaitForChild("Level Manager")
local GS = LevelMan:WaitForChild("GameStarted")
local IIL = LevelMan:WaitForChild("IsInLobby")
local Lobby = script:WaitForChild("Lobby")
local Battle = script:WaitForChild("Battle")
function PlayStopSound(sound,play)
if play then
print("Sound Manager: Playing "..sound.Name)
sound:Play()
else
print("Sound Manager: Stopping "..sound.Name)
sound:Stop()
end
end
function PlaySounds()
local function PlayLobby()
if IIL.Value == true then
PlayStopSound(Lobby,true)
else
PlayStopSound(Lobby,false)
end
end
PlayLobby()
IIL.Changed:connect(function()
PlayLobby()
end)
local function PlayBattle()
wait(1)
if GS.Value == true then
PlayStopSound(Battle,true)
else
PlayStopSound(Battle,false)
end
end
PlayBattle()
GS.Changed:connect(function()
PlayBattle()
end)
end
PlaySounds()

2 comments
Maybe the sound id isn't valid?
I guess not because the sound plays the first rime.