Skip to Content
Kinemium

IntConstrainedValue

Store an integer clamped between a minimum and maximum.

IntConstrainedValue is an integer with bounds. Assigning a value outside the range stores the nearest bound, and ConstrainedValue returns the clamped result.

Getting started

local value = Instance.new("IntConstrainedValue")
value.MinValue = 1
value.MaxValue = 5
value.Value = 9

print(value.Value)            -- 5
print(value.ConstrainedValue) -- 5
value.Parent = configFolder

Properties

PropertyTypeAccessDefaultDescription
ValuenumberRead/write0The stored integer, clamped on assignment.
ConstrainedValuenumberRead-only0The current value clamped to the range.
MinValuenumberRead/writeLowest 64-bit integerLower bound.
MaxValuenumberRead/writeHighest 64-bit integerUpper bound.

Fractional assignments are truncated to an integer before the clamp. Value keeps the stored value when the bounds change; ConstrainedValue applies the current bounds.

Notes

  • Inherits from ValueBase, which adds no members.
  • The default bounds cover the full 64-bit integer range.
  • Min and max aren't ordered for you; keep MinValue <= MaxValue.
  • Cloning copies the value and both bounds.

See also

  • IntValue for an unconstrained integer.
  • DoubleConstrainedValue for the decimal version.

On this page