Cannot add numbers

I have been trying to add x to y multiple times to get z, which is constantly expanding by an increment of x.
The issue, however, is that z stays the same.
I have tried multiple solutions, but none of them work.
The code I’m using is

while wait(1) do
	local increment = 31.8
	local int = 0
	int = int + increment
	print(int)
end

The output is just 31.8 (31.8 (x41)) over and over, while the expected output would be 31.8, 63.6, 95.4, etc etc
This is probably just a dumb mistake, but any help is appreciated.

This is because variables are defined INSIDE the loop.
You need to define them outside, otherwise they will just keep being set to 31.8 and 0.
Let me know if you have questions! <3

2 Likes

Thanks! I haven’t used luau in a while, and I was just being dumb. Thanks for the help!

1 Like

Any time! And no worries! Easy to forget stuff. xD

1 Like