TakeDamage (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens I didn't know it could be used to heal. But I believe healing should still be possible when a player has a forcefield, and, anyways, the purpose of this method is to give damage to an humanoid, not to heal it! |
>Tomtomn00 →Example: code |
||
Line 11: | Line 11: | ||
This code, put in a [[RBX.lua.LocalScript (Object)|LocalScript]], would make the local player take 99 damage. | This code, put in a [[RBX.lua.LocalScript (Object)|LocalScript]], would make the local player take 99 damage. | ||
<code lua>game.Players.LocalPlayer.Character.Humanoid:TakeDamage(99)</code> | |||
== Healing == | == Healing == |
Revision as of 16:05, 10 April 2012
![]() | |
Returns | nil |
Description: | Subtracts the damage from the health of the targeted humanoid unless the character has a ForceField. |
Member of: | Humanoid |
Example
This code, put in a LocalScript, would make the local player take 99 damage.
game.Players.LocalPlayer.Character.Humanoid:TakeDamage(99)
Healing
This method, though not designed for healing, can be used to heal a character by using a negative number. However, note that healing will not work if the character has a ForceField, just as if the character was taking damage.
Example
This code, assuming the variable humanoid is defined to an humanoid, would heal that humanoid by a value of 10, unless that humanoid is protected by a ForceField.
humanoid:TakeDamage(-10)