I want to update a value when a player dies, how would I do that?
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.