Died (Event)

(Redirected from Died)
Died ( )
Description Fired after a Humanoid's health reaches 0.
Member of: Humanoid


Description

The Died event is triggered when Humanoid "dies" either because Health is 0 or because the Head and Torso are disconnected (Broken joints or one or both is removed). You can prevent deaths through depleted health by keeping your health constantly above 0.

The event occurs after the automatic BreakJoints in model upon death, but before character falls and is removed.

Example

The code below would print A player has died. whenever a player dies.

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		for _, child in next, character:GetChildren() do
			if child:IsA('Humanoid') then
				child.Died:connect(function()
					print("A player has died.")
				end)
			end
		end
	end)
end)