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

Player Dying

Asked by
Trewier 146
11 years ago

I want to update a value when a player dies, how would I do that?

2 answers

Log in to vote
3
Answered by
coo1o 227 Moderation Voter
11 years ago

NOTE: The code here is untested.

Use the Died event of humanoids.

1workspace.Player.Humanoid.Died:connect(function()
2print('Player died!')
3end)

Then we just incorporate a value.

1local dead = false
2 
3workspace.Player.Humanoid.Died:connect(function()
4dead = true
5end)

To make it work with anybody that joins the game, use PlayerAdded.

1local dead = false
2 
3game.Players.PlayerAdded:conect(function(player)
4repeat wait() until player.Character
5player.Character.Humanoid.Died:connect(function()
6dead = true
7end)
8end)

~coo1o

Ad
Log in to vote
0
Answered by 11 years ago

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.

2
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. coo1o 227 — 11y

Answer this question