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

How would i make a audio play upon death?

Asked by 8 years ago

So heres what i tried [I'm not very good at scripting] Trial #1 game.workspace.Players.LocalPlayer if health = 0 then wait (0.1) game.workspace.Audio1.play

Trial #2 game.workspace.Players.LocalPlayer Health=H If H = 0 then wait(0.1) game.workspace.Audio1.sound

2 answers

Log in to vote
-1
Answered by 8 years ago
game:GetService('Players').PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(plr2)
        plr2:WaitForChild("Humanoid").Died:connect(function()
            game.Workspace.YourAudio:play()
        end)
    end)
end)

That should work. It just checks if the Humanoid has died and if it does it plays the music.

Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

Nice attempt. I just grabbed this script from the Wiki's page on the Died event

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            game.Workspace.Audio1:Play()
        end)
    end)
end)
0
I tried both of the answers neither of them worked. I placed the audio in workspace and then replaced Audio1 and Your Audio With the audio's name. It didn't work. Jakuten 5 — 8y

Answer this question