Alienhead Posted December 21, 2022 Posted December 21, 2022 local number = 10 number = math.clamp(number,1,5) Errors out, The the docs read - This function clamps a number between a minimum and maximum limit and returns the result. Even the standard lua call errors on me. Math.Clamp () / math.Clamp() / math.clamp() or simply: ?? function math.clamp(numb, min, max) if numb < min then return min elseif numb > max then return max else return numb end end Quote Alienhead Components and Software
Josh Posted December 22, 2022 Posted December 22, 2022 "number" is a type in Lua, so I think that isn't a valid variable name. Quote Let's build cool stuff and have fun.
Genebris Posted December 22, 2022 Posted December 22, 2022 1 hour ago, Josh said: "number" is a type in Lua, so I think that isn't a valid variable name. Interestingly, it does work. In some online interpreter at least. I guess it's because variable doesn't have a type, only value has a type. 1 Quote
Josh Posted December 22, 2022 Posted December 22, 2022 local number = 10 number = Math:Clamp(number,1,5) 1 Quote Let's build cool stuff and have fun.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.