getElementHealth | Multi Theft Auto: Wiki Skip to content

getElementHealth

Client-side
Server-side
Shared

Pair: setElementHealth

This function returns the current health for the specified element. This can be a player, ped, vehicle, object or weapon.

OOP Syntax Help! I don't understand this!

  • Method:element:getHealth(...)
  • Variable: .health

Syntax

float|false getElementHealth ( ​element theElement )
Required Arguments
  • theElement: The element whose health you want to check.

Returns

  • float|false: health

Returns a float indicating the element's health, or false if invalid arguments were passed.

Code Examples

shared
OOP Required
local function isPlayerInjured(player)
if (not player) then
return
end
local hp = player.health
return hp < 100
end
local plr = Player("Bob")
print(isPlayerInjured(plr))

See Also

Element Functions