Home / Player

p:health() / p:setHealth()

p:health() p:setHealth(value)

Reads or changes the player's health.

Parameters

NameTypeDescription
valuenumberNew health value for setHealth. Automatically clamped to 0..20.

Returns

p:health() returns the current health as a number. p:setHealth() returns nothing.

Example

command('heal', { op = true }, function(sender)
  if not sender.isPlayer then return true end

  sender:setHealth(20)
  sender:send(color.green .. "Health restored.")
  return true
end)