How do I break out of a specific "for i, v in pairs" loop?

So I have a for loop inside of a for loop.

This is a visualization of what i’m talking about but not the whole script:

for i, v in pairs() do
	if then
		for n, t in pairs() do
			if then
				--I want to break out here
			end
		end
	end
--To here
end

How will I be able to do that?

3 Likes

I think in your case you’d just break out of it

for i, v in pairs() do
	if then
		for n, t in pairs() do
			if then
				break
			end
		end
	end
--To here
end

It would break out of the n,t pairs look and continue to under the first if statement

2 Likes

I think add variable and another check.

Like:


local IsBreak = false

if statement then IsBreak = true break end

if IsBreak then break end
1 Like

I tried doing that, but it will be the same thing as just putting a break inside the if statement I already have.

1 Like

nvm, I didn’t understood what you wanted

2 Likes