for i, v in pairs(game.Workspace.Model1:GetChildren()) do
local intValue = v:FindFirstChild("DataValuel")
if v.intValue.Value == 0 then
----do a thing
break
end
end
end
As you guys can see, this is an issue because if the code iterates through a brick that does not have an IntValue in it or that has an IntValue but it is not set to 0 then the loop will end, I want to make it so that it will iterate through all of the bricks, and then upon iterating the correct one which is one that has a value of 0 it will do something. Removing the break does what I want, however then it will run more than once, which is what I do not want. Any ideas?
Maybe I create another if statement that checks local variable is ture and at the end of --do a thing I set it to false? I will try that it might work.

4 comments
I'm lost; what're you trying to do?
I want my for i v statement to check ALL bricks in my Model for ones that meet certain conditions and then to do something to ONLY one of the bricks that meet the certain conditions and then for the for loop to end. I tried using a break but if the for i v statement happens to come across a brick that does not meet the conditions itll just end the loop which is not what I want. Is that clearer?
Yes, it does. When looping through the item, you could check it via if some values (such as names, colours, etc). However, with your code, on line 3, you're essentially retyping line 2; you don't need to rewrite the original when you already have it defined. :P
Ah that was a small typo, but see i still am running ingo thr issues described above. If the for i v loop happens to iterate on a brick that does not have an IntValue set to 0, the loop will exit because of the break which is not what I want it to do. I want it to iterate all bricks regardless if they dont have the value but upon finding one that does have a value, for it to do something to do the