I want to update a value when a player dies, how would I do that?
✓ ANSWER ACCEPTED
Player Dying
2 answers
✓ Accepted answer
NOTE: The code here is untested.
Use the Died event of humanoids.
workspace.Player.Humanoid.Died:connect(function()
print('Player died!')
end)
Then we just incorporate a value.
local dead = false
workspace.Player.Humanoid.Died:connect(function()
dead = true
end)
To make it work with anybody that joins the game, use PlayerAdded.
local dead = false
game.Players.PlayerAdded:conect(function(player)
repeat wait() until player.Character
player.Character.Humanoid.Died:connect(function()
dead = true
end)
end)
~coo1o
LocalPlayer.CharacterRemoving That's an event that fires after the LocalPlayer dies. It would help to distinguish player death from player left within your script.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It's not best to use CharacterRemoving for a script that only detects death because it runs ANY time the player's character is removed, say like when the player leaves.