I have the loop finding the names of frames in "Slots". I want the loop to end once it found just one slot that fits the category. If there are other slots as duplicates I want them to be left alone. How do I do this?
for i,v in pairs(Slots)do
if v:IsA("Frame")then
if v.Name == BeltName then
v:Destroy()
for _,R in pairs(Slots)do
if R.Name ~= v.Name then
if R.Position == v.Position then
R.SlotUsed.Value = "false"
v:Destroy()
break
end
end
end
end
end
end

3 comments
Holdup I think I solved it by using return instead of break, But I'm still testing it.
Remember that "return" in most languages including Lua usually refers to the act of returning a value or values from a function/method. Using return in this context could cause some confusion. The difference between break and return are that break exits out of the loop in context, while return exits out of the function in context.
Lol, I fixed it but I'll keep it here just for further refrence.