Died (Event): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>GoldenUrg initial from memory |
>JulienDethurens No edit summary |
||
(28 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{Event | |||
|name = Died | |||
|description = Fired after a Humanoid's health reaches 0. | |||
|object = Humanoid | |||
|description= Fired after a Humanoid | }}</onlyinclude> | ||
|object= | |||
{{clear floats}} | |||
</onlyinclude> | |||
== Description == | == Description == | ||
Died event is triggered when Humanoid "dies" either because [[ | 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. | The event occurs after the automatic BreakJoints in model upon death, but before character falls and is removed. | ||
Line 15: | Line 14: | ||
== Example == | == Example == | ||
< | The code below would print <samp>A player has died.</samp> whenever a player dies. | ||
player. | |||
game | {{code|= | ||
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) | |||
}} | |||
[[Category:Events]] | [[Category:Events]] |
Latest revision as of 20:26, 9 April 2012
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)