Overview
A clamp function returns the lower bound when a value is too small, the upper bound when it is too large, and the original value when it is already inside the range.
This Arsenal resource is a manual planning or learning aid. It does not connect to a Roblox account, inspect live game state or automate gameplay.
What this resource covers
- Input value
- Minimum and maximum bounds
- Boundary behaviour
- Reusable helper function
How to use it
- Read the helper and identify its three possible outcomes.
- Test a value below the minimum.
- Test a value inside the range and above the maximum.
- Add validation for reversed bounds if the function will be reused.
Worked example
With bounds 0 and 100, clamping -5 returns 0, 42 returns 42 and 120 returns 100. These are arithmetic examples, not Arsenal game settings.
Limitations and verification
The function does not read or change Arsenal settings. Decide how your project should handle non-numeric input and minimum values greater than maximum values.