IntValue Not Changing

Hi. Pretty self explanatory. My code:

script.Parent.Changed:Connect(function()
if script.Parent.Value > 3 then
script.Parent.Value = 3
end
if script.Parent.Value < 1 then
script.Parent.Value = 1
end
end)

while true do
wait(.3)
if script.Parent.Value >= 3 then
if script.Parent.Value <= 1 then
script.Parent.Value = script.Parent.Value + .01
end
end
end

1 Like

A value can’t be bigger or equal to 3 and be smaller or equal to 1. You’ll have to remove 1 of those statements to make it work.

1 Like

It is changing in the function loop, but not the while loop.

Oh, right thanks, I’m a complete idiot. I meant less than or equal to 3 and greater than or equal to 1.

1 Like

:laughing: It’s alright. Everyone makes dumb mistakes here and there.

Wait, I still need help. My revised code is still not working :frowning:
@THECOOLGENERATOR

I have 2 iterations:
The first:

script.Parent.Changed:Connect(function()
if script.Parent.Value > 3 then
script.Parent.Value = 3
end
if script.Parent.Value < 1 then
script.Parent.Value = 1
end
end)

while true do
wait(1)
if script.Parent.Value <= 3 then
if script.Parent.Value >= 1 then
script.Parent.Value = script.Parent.Value - .01
end
end
end

The second:

while true do
wait(.3)
if script.Parent.Value > 3 then
script.Parent.Value = 3
end
if script.Parent.Value < 1 then
script.Parent.Value = 1
end
if script.Parent.Value > 1 then
wait(.7)
script.Parent.Value = script.Parent.Value - .01
end
end

Are these two loops both in the same script?

No, separate scripts. I don’t know what the problem is.

Try adding print statements to see what runs and what doesn’t. Also, are you getting any errors?

No errors. It doesn’t print anything within the while loop. I’ll have to check for the function loop.

For the function loop, it prints but does not change the value.
The print is within the final “if” statement

Instead of two separate if statements, try adding an elseif.

Apparently it does the same with the while loop. The printing and not changing.

Wait, what’s the value of the IntValue currently?

1, at the beginning. Also, I think the problem may be that you can’t make a decimal an intvalue

Yeah maybe, that slipped my mind. Try adding/subtracting an integer instead of a float/decimal.

Yeah, IntValues don’t support decimal numbers and only work with whole numbers. You should consider switching to NumberValues instead, or changing your integar counter to a whole number.

1 Like

I will switch to number values. Thanks to all that helped!