How does break work in a nested loop?

i want the inner loop to break but not the outer, would this work?

    for i = 1, player.OtherStats.MaxPetsEquipped.Value do 
		for key, value in pairs(bestDict) do
			if value == values[i] then
				selectedTemplate = scrollFrame:FindFirstChild(key)
				onEquip()
				break
			end
		end
	end

Just for what it’s worth, in the fifteen minutes it took to type that and wait for a response, you could have tested it yourself.

for i = 1, 10 do
    print("loop 1")
    for x = 1, 10 do
        print("loop 2")
        break
    end
end

Give that a go and see what you get.

4 Likes

Yes it would, break/continue statements only affect the immediate enclosing iteraction structure.

Don’t forget to mark this reply as the solution.