Skip to main content

Mathf.Clamp(number value, number min, number max)

Clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range.

Parameters:

NameTypeDescription
valuenumberThe floating point value to restrict inside the range defined by the min and max values.
minnumberThe minimum floating point value to compare against.
maxnumberThe maximum floating point value to compare against.

Returns:

typeDescription
numberThe result between the min and max values.

Usage

---@type number
local value;

---@type number
local min;

---@type number
local max;


local val0 = Mathf:Clamp(value, min, max)