I made a variable for a part of my script but this doesnt seem to work, the print is so I know what the value is, why doesn't it work?
local wag = 44 while true do for i = 1, 45 do if wag <= -44 then wag = wag+1 wait(.5) elseif wag >= 44 then wag = wag-1 wait(.5) end end print(wag) end
EDIT: Can someone fix this so it goes from 44 to -44 then back up?
I'm gonna show a way that's different - using a bool switch. Bool switches are just variables that you turn "on" and "off" each iteration.
You check the bool switch and execute code accordingly.
local wag = 44; --number local bool = false; --bool switch local MIN,MAX = -44,44 --bounds while true and wait() do if wag < MIN or wag > MAX then --If number is out of bounds bool = not bool --switch the bool end wag = (bool and wag + 1) or wag - 1 --increment value according to bool print(wag) end