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

Is there an event that is triggered when a player dies?

Asked by
P100D 590 Moderation Voter
8 years ago

I would need to use it to award the kill to the killer. Is there a specific triggered event, or will I have to script my own detector?

1 answer

Log in to vote
1
Answered by
funyun 958 Moderation Voter
8 years ago

Yes, there's an event of Humanoids for when they die.

--LocalScript in StarterPlayer.StarterPlayerScripts

player = game.Players.LocalPlayer
repeat wait() until player.Character
character = player.Character
humanoid = character:WaitForChild("Humanoid")

humanoid.Died:connect(function() --Using the "Died" event of Humanoids
    print("ded")
end)

Unfortunately you won't be able to know who killed him, only when he died. So no, you can't use this to directly award points to the killer. You'll have to figure something out.

Ad

Answer this question