Scripting / Humanoid
Humanoid:TakeDamage()
Reduces a Humanoid's authoritative Health by a non-negative amount.
Syntax
humanoid:TakeDamage(amount)Availability
TakeDamage() is an authoritative server operation and is available to public ServerScript code. Calling it from a public LocalScript is rejected.
Parameters
| Name | Type | Description |
|---|---|---|
amount | number | Amount of health to remove. Negative amounts do not heal the Humanoid. |
The amount must be finite. Health is clamped to the Humanoid's valid health range.
Example: Damage On Touch
Luau
script.Parent.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")
if humanoid then
humanoid:TakeDamage(25)
end
end)Death
If the damage reduces Health to zero, the Humanoid becomes dead and its Died signal fires for active connections. This works for both player Humanoids and authored NPC Humanoids.
A dead NPC character uses the same physics-driven R6 breakup used for player character death. NPCs are not automatically respawned.