Skip to main content

Health

Controls health and damage.

info

This module can only be used in Entity scripts.

Functions

getHealthPercent(subject)

Returns the relative health a target has from 0 to 1.

Parameters

  • subject Object to check health of.

Returns

Percent of health [0, 1].


getHealth(subject)

Returns the target's current health value.

Parameters

  • subject Object to check health of.

Returns

Health amount.


getMaxHealth(subject)

Returns the target's current maximum health value.

Parameters

  • subject Object to check health of.

Returns

Maximum health amount.


setInvulnerable(subject, invulnerable)

Sets the invulnerability status of the target.

Parameters

  • subject Object to modify.
  • invulnerable If true object won't take any damage. If false object will be damaged as regular.

setHealth(subject, amount)

Sets the target's health. This method won't trigger any particles or numbers for health increase or decrease. For better visual feedback use Heal() or Damage() methods.

Parameters

  • subject Object to set the health of.
  • amount Health amount. Negative values will destroy the target immediately.

setMaxHealth(subject, amount, healToMax)

Sets maximum health that the target can have.

Parameters

  • subject Object to set max health of.
  • amount Amount of max health. Minimum value of 1.
  • healToMax If the target's current health should be set to its new maximum. Optional value.

heal(subject, amount)

Heal target.

Parameters

  • subject Object to heal.
  • amount Heal amount. Can be negative to apply damage instead.

healMax(subject)

Sets the target's health to its maximum value.

Parameters

  • subject Object to heal.

setRegenStart(subject, amount)

Sets the delay after taking damage before health begins to regenerate.

Parameters

  • subject Object to change regeneration of.
  • amount Delay in seconds until regen starts. Setting to 0 or lower will start healing immediately after taking damage.

setRegenDelay(subject, amount)

Sets the delay between instances of health regeneration.

Parameters

  • subject Object to change regeneration of.
  • amount Delay in seconds between each regeneration. Setting to 0 or lower will heal every network tick.

setRegenAmount(subject, amount)

Sets the amount of health to restore after every regeneration delay.

Parameters

  • subject Object to change regeneration of.
  • amount Amount of health to restore each time the delay ends. Setting to 0 or lower will disable regeneration.

setCollisionDamageFactor(subject, factor)

Sets the amount of damage dealt when the target collides with another object.

Parameters

  • subject Object to set collision factor of.
  • factor The factor of damage relative to the velocity of the object when collision happened. Higher values will damage object more. Default is 0 which means object doesn't take collision damage.

damage(subject, amount, damager)

Damages target.

Parameters

  • subject Object to damage.
  • amount Amount of damage to apply. Can be negative to heal instead.
  • damager Either the Player, client ID of the player that caused the damage, or -1 to assign the damage to no player in particular.