Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sound doesn't play?

Asked by 9 years ago

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()
0
Maybe the sound id isn't valid? TheDeadlyPanther 2460 — 9y
0
I guess not because the sound plays the first rime. DragonOfWar900 397 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

There is usually an error that says:

Sound failed to load.

That may be your problem.

BTW: We can't fix it. A really bad roblox update did that I think.

Ad

Answer this question