[HELP] Restrict a value to a given range

I checked the expressions references article and when it comes torestricting a value to a given range it says that we should use clamp(number, number, number) for value, min, max.

But upon writing: clamp(5,0,100) as action without condition, the value is not able to change from 5 (obviously) and when I place it “at the beginning of the scene” then it does nothing as it’s still able to go under 0 and over 100.

What can I do when I want to start with 5 and for the rest of the game to be unable to go under 0?

Can you provide screen snippets of what you’re doing? I’m suspecting you’ll need to use clamp like
Variable(someVar) = clamp(Variable(someVar) + Variable(someIncrement), 0, 100). Just using clamp(5,0,100) will always result in 5.

Placing it at the beginning of the scene means it only gets executed once at the start of the scene. It’s not the right place to put it.

1 Like

Please post a screenshot of your events, if we can’t see what you did it is hard to help.

the easiest solution in the first sight without knowing any detail is:
check if Variable < 0 :arrow_right: than do Variable = (set to) 0

1 Like