Builtin Library
README.md
math.clamp (procNode)
The value held between a lower and an upper bound, element by element.
The clamp operation of the authoring surface, called through the Luau node on proc.fieldc.operators. Operands are numbers, vectors, Columns or Fields. When every operand is a plain number or vector the answer is the plain result, folded where the node cooks; otherwise the answer is a Field: a template over its operands that whatever reads it evaluates in one dispatch together with the chain around it. Nothing dispatches for this node alone. Over numbers and animated values the answer is an animated value: the operation at every time.
The answer is min(max(value, min), max), so with min above max it is max. Both bounds default to 0: give them, or every value clamps to 0.
Operands of different widths widen to the widest: a number applies to every component, and a shorter vector reads 0 for the components it lacks.
Inputs
value(Value, default 0). The value held.min(Value, default 0). The lower bound.max(Value, default 0). The upper bound.
Outputs
value. The clamped value.
local value = g.math.clamp(5, 0, 2) -- 2