Revision Difference
Entity:SetHealth#514694
<function name="SetHealth" parent="Entity" type="classfunc">⤶
<description>⤶
Sets the health of the entity.⤶
⤶
<note>You may want to take <page>Entity:GetMaxHealth</page> into account when calculating what to set health to, in case a gamemode has a different max health than 100.</note>⤶
</description>⤶
<realm>Shared</realm>⤶
<args>⤶
<arg name="newHealth" type="number">New health value.</arg>⤶
</args>⤶
</function>⤶
⤶
<example>⤶
<description>Sets the entity's health to their maximum health.</description>⤶
<code>Entity( 1 ):SetHealth( Entity( 1 ):GetMaxHealth() )</code>⤶
<output>The entity's health is now full.</output>⤶
⤶
</example>⤶
⤶
⤶
<example>⤶
<description>Deducts 50 points of health from the entity.</description>⤶
<code>Entity( 1 ):SetHealth( Entity( 1 ):Health() - 50 )</code>⤶
<output>The entity now has 50 less health.</output>⤶
⤶
</example>