How to make continue skip another loop?

Hi,

So i have this thing:

for _, i in pairs(Inventory:GetChildren()) do
			
	for _, v in pairs(script.Parent.Frame:GetChildren()) do
		if v:IsA("ImageLabel") then
			if v:WaitForChild("Button"):WaitForChild("ItemFromInventory").Value == i then continue end
		end		
	end

end

I want if ImageLabels value “ItemFromInventory” is the same thing as i to skip this thing and go to next, but the problem is that continue in this case skips my loop with script.Parent.Frame:GetChildren() and not with Inventory:GetChildren().

i tryed making function like this inside i loop:

local function skip()
	continue
end

but it says that continue should be inside loop :frowning:

How can i make it skip current i and not v ?

Oh i figured this out

I made my script something like this:

for _, i in pairs(Inventory:GetChildren()) do
	local same = false	
	for _, v in pairs(script.Parent.Frame:GetChildren()) do
		if v:IsA("ImageLabel") then
			if v:WaitForChild("Button"):WaitForChild("ItemFromInventory").Value == i then same = true end
		end		
	end
    if same == true then
        continue
    end

end

This won’t do anything in the way you’ve currently set it up. By the time it continues, the iteration is already finished and it was about to go to the next iteration anyway.

The only time continue is useful is if there’s more code after it in the same loop that you don’t want to run for that iteration.

i use this to update inventory, but since my inventory updates often i don’t want to delete all buttons and create new so i decided to make it so i will just add one more button or few if i got more items in inventory. Also i got alot of more content after this continue. i just don’t showed it since i don’t have any issue with it.

No worries, just making sure you weren’t blindly using it, and for anyone else who stumbles upon the topic.

You can also break after setting same to true to exit that inner loop as soon as you match the condition. It probably won’t make much difference unless the inner loop is very large.