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

How to make music stop repeating when you die?

Asked by 7 years ago
Edited 7 years ago

I don't want the music to repeat when the person dies

MUSIC01 = game.Workspace.AmbientMus01
MUSIC02 = game.Workspace.AmbientMus02
while wait() do
    wait(1)
        MUSIC01:Play()
print("FIRST STARTED")
    wait(118)
        MUSIC01:Stop()
print("DONE")
    wait(2.5)   
        MUSIC02:Play()
print("SECOND STARTED")
    wait(96)    
        MUSIC02:Stop()
print("DONE")
    end

I've tried making a checker but that didn't work i also tried waiting for the character (both times the sound didn't even play) I looked for a property in Humanoidor anywhere else in character and i tried putting it in Workspace and ServerScriptStorage Is there anyway to stop this from restarting?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died

Died event is fired when the player dies

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            MUSIC:Pause() --To whatever your music name is
        end)
    end)
end)

http://wiki.roblox.com/index.php?title=API:Class/Sound/Pause

0
Why would i want the music to stop though ?? wouldnt i want it to pause and then resume it ? arrowman888 69 — 7y
Ad

Answer this question