Garry's Mod Wiki

Entity:SetHealth

Entity:SetHealth( number newHealth )

Description

Sets the health of the entity.

You may want to take Entity:GetMaxHealth into account when calculating what to set health to, in case a gamemode has a different max health than 100.

Arguments

1 number newHealth
New health value.

Example

Sets the entity's health to their maximum health.

Entity( 1 ):SetHealth( Entity( 1 ):GetMaxHealth() )
Output: The entity's health is now full.

Example

Deducts 50 points of health from the entity.

Entity( 1 ):SetHealth( Entity( 1 ):Health() - 50 )
Output: The entity now has 50 less health.

Page Links


Special Pages


Wikis

?

Render Time: 25ms

DB GetPage 3
Generate Html 2
SaveChanges (1) 11
Render Body 0
Render Sidebar 7