Entity/SetHealth

From Garry's Mod
Jump to: navigation, search
 Entity:SetHealth( )

Contents

Description

Sets the health of the entity.

NOTE

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

number newHealth

New health value.

Examples

Example

Sets the entity's health to their maximum health.

Entity( 1 ):SetHealth( Entity( 1 ):GetMaxHealth() )

Output:

The entity's health is now full.

Examples

Example

Deducts 50 points of health from the entity.

Entity( 1 ):SetHealth( Entity( 1 ):Health() - 50 )

Output:

The entity now has 50 less health.
Personal tools
Navigation