Died (Event)

From Legacy Roblox Wiki
Revision as of 17:31, 28 March 2012 by >Nightname
Jump to navigationJump to search
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
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)