[HELP] How do I break a for i loop inside a while true do?

Hi developers, today I was trying to do a for i, inside a loop. like this:


The problem is that I want to stop the for i, and not the while task.wait() do. What I can do?
I would appreciate your support, sorry for my grammar I use a translator

1 Like

break should only be breaking the for i as a second break outside of the for i would be needed to stop the while do
Is it not doing just that?

Breaking inside the for i loop will break itself. If you break outside of the for i loop however, then it’ll break out of the while loop.

look: @Pseudoisochromatic @RefusalMan

while task.wait() do
	print("WHILE TRUE DO ACTIVATE")
	timer = 15 -- Wait time before teleport change to whawtever you want it to be
	
	if #PlayerList >= 1 then
		
		for i = 1,timer do
			print("FOR I ACTIVATE")

			timer = timer - 1
			BillBoard.Frame.time.Text = timer
			wait(1)
			
			if #PlayerList == 0 then
				BillBoard.Frame.time.Text = 15
				timer = 15
				print("BREAK!!!")
				break
			end
		end
		teleportPlayers()
		
	end
end

https://gyazo.com/658bd6f1b89fc0f4bfee86a4ebe2c353
the while task.wait stops and I don’t want that

That’s because you’re yielding in each loop of the for i (with the wait(1) calls). The while do will retry after the for i is done.

Is there any way to do it?, because the loop is very important in the script that I am doing, pls help

Your while do is fine, it’s just waiting for the for i to end before starting over.

If I do that, the system will no longer work. I will try to do some research on this