December 22, 2022, 3:25am
I have tried to use the math.Clamp function but I’m quite confused as it does not constrain my int value. I need a way to set a maximum and minimum number so the int value cannot go above or below the number.
This is what I have tried so far
page.Value = page.Value + math.clamp(1,0,2)
December 22, 2022, 3:35am
In your code,
math.clamp(1,0,2) clamps the number literal constant
1 as this is placed in the first (named “n”) argument rather than the IntValue so it does not constrain the IntValue as expected.
December 22, 2022, 3:36am
You need to clamp the entire thing:
page.Value = math.clamp(page.Value + 1, 0, 2)
Your current code clamps 1 between 0 and 2 which is just 1 since 1>0 and1<2.
December 22, 2022, 3:38am
Thanks this makes sense now ty for the help
January 5, 2023, 3:38am
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.