As some of you may already be aware, TheGamer101 had recently announced on the devforum that two new math functions arriving for the developers of ROBLOX to use in their creations.
What are these functions?
The two new functions are Math.Sign, and Math.Clamp. These are already things you can do in Lua with the aid of math knowledge, although they provide a simpler, cleaner & much more efficient way of presenting them.
Below are examples of how they work:
math.clamp(number x, number min, number max)
- If min is greater than max, an error is thrown indicating that min must be less than max
- If x is less than min, it returns min
- If x is greater than max, it returns max
- If any argument is missing, nil, or otherwise not a number, an error will be thrown stating this
Otherwise, it returns val
- Returns 1 if x is greater than 0, -1 if x is less than 0, or 0 if x is 0.
Please be aware that I do not take credit for any of this & intend for this to be purely informational for those that don't go onto the devforum often.