- Documentation
- Shared functions
- math.clamp
Function
math.clamp
Clamps a number to the range from lo to hi.
Syntax
math.clamp(value, lo, hi)Arguments
valuefloat- The number.
lofloat- Lower bound.
hifloat- Upper bound.
Returns
The clamped number.
Example
addCommandHandler("hp", function(player, cmd, amount)
setElementHealth(player, math.clamp(tonumber(amount) or 100, 1, 100))
end)