This returns -1 in the output.
local myVariable = 100
myVariable = math.clamp(myVariable,0,100)
myVariable = -1
print(myVariable)
This returns -1 in the output.
local myVariable = 100
myVariable = math.clamp(myVariable,0,100)
myVariable = -1
print(myVariable)
It takes 3 values. X, min and max. If X is in the range between min and max it returns X. If X is lower than min it returns min and if X is higher than max it returns max.
You are setting the value to -1 after your clamp therefore it prints -1.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Do you want it to return -1?
No, i'm setting the minimum value to 0, therefore it shouldn't print "-1", and i did a while loop with this aswell, and it got past the minimal value, which is 0, i don't understand.
The reason it prints -1 is because you are setting the variable to -1 after your other Variable