Died (Event): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Nightname No edit summary |
>Flurite No edit summary |
||
Line 12: | Line 12: | ||
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. | ||
{{Example| | {{Example|{{code|= | ||
local function onDied(character) | local function onDied(character) | ||
--do on death | --do on death | ||
Line 28: | Line 28: | ||
game.Players.PlayerAdded:connect(onPlayerAdded) | game.Players.PlayerAdded:connect(onPlayerAdded) | ||
}}}} | |||
[[Category:Events]] | [[Category:Events]] |
Revision as of 20:08, 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
local function onDied(character)
--do on death
end
local function onCharacterAdded(character)
character.Humanoid.Died:connect(function()
onDied(character)
end)
end
local function onPlayerAdded(player)
player.CharacterAdded:connect(onCharacterAdded)
end
game.Players.PlayerAdded:connect(onPlayerAdded)