TakeDamage (Method): Difference between revisions
From Legacy Roblox Wiki
Jump to navigationJump to search
>Flurite spelling and rewording |
>Tomtomn00 |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<onlyinclude>{{Method | <onlyinclude>{{Method | ||
|name = TakeDamage | |name = TakeDamage | ||
|arguments = | |arguments = {{type|float}} <var>amount</var> | ||
|description = Subtracts the damage from the health of the targeted humanoid unless the character has a [[ForceField]]. | |description = Subtracts the damage from the health of the targeted humanoid unless the character has a [[RBX.lua.ForceField (Object)|ForceField]]. | ||
|object = Humanoid | |object = Humanoid | ||
}}</onlyinclude> | }}</onlyinclude> | ||
Line 8: | Line 8: | ||
{{clear floats}} | {{clear floats}} | ||
== Example == | |||
game.Players.LocalPlayer.Character.Humanoid:TakeDamage(99) | This code, put in a [[RBX.lua.LocalScript (Object)|LocalScript]], would make the local player take 99 damage. | ||
</ | {{code|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 [[RBX.lua.ForceField (Object)|ForceField]], just as if the character was taking damage. | |||
=== Example === | |||
This code, assuming the variable <var>humanoid</var> is defined to an humanoid, would heal that humanoid by a value of 10, unless that humanoid is protected by a [[RBX.lua.ForceField (Object)|ForceField]]. | |||
{{code|humanoid:TakeDamage(-10)}} | |||
[[Category:Methods]] | [[Category:Methods]] |
Latest revision as of 16:06, 10 April 2012
TakeDamage( float amount ) | |
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)