Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I set an IntValue so that it has a limit?

Asked by
Yeevivor4 155
9 years ago
function checkforzero()
    if Fish.Value == 0 then
    return nil
    end
end
script.Parent.MouseButton1Click:connect(checkforzero)

Hello, thank you for reading. I was wondering, how do I set a IntValue so that it has a limit. Let's say I want the limit to be 0. How would I script it so that if 0 was the limit, it would not go down to -1 or anything lower. Thank you for reading.

0
Thank you for the hookup with the wiki. Yeevivor4 155 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

Check if it goes below then re assign it to 0

Fish.Changed:connect(function()
if Fish.Value < 1 then
Fish.Value = 0
end
end)

Or alternatively, when editing the value, check if the result will cause it to go below 0

takeaway = 50
if not Fish.Value - takeaway < 0 then
Fish.Value = Fish.Value - takeaway
end

Or use both in collaboration.

Ad

Answer this question