I have a for loop looking like this: for i = 90,1,-1 do The for loop is inside a while true do loop When I use break to stop the for loop its stops it after while true do repeats How can I make the for loop stop but when the while loop starts it will work again? Can anyone help me out?
Using break
will exit the current loop.
Also, you could set a variable and check if that variable is true before running your loop so you can control whether it will run or not.
local runForLoop = true while true then if runForLoop then for i = 90, 1, -1 do if i == 45 then runForLoop = false break end end end wait() end
The script above will set runForLoop
to false and stop running the loop when i
is 45.
If you want the for loop to start working again, simply set runForLoop
to true.