local children = script.Parent.Parent:GetChildren() for i = 1, #children do if children[i]:IsA("BasePart") then -----should a break go here------- print("script ran") -----or here?--------- end end
I want the loop to break when children[i] is a basepart.
for the code under the for loop and the if statement, were is the best place to put a break.
Now that I understand the question, break goes after any code you want to run. Code executes top to bottom, so generally put break after any code you want to run.
local children = script.Parent.Parent:GetChildren() for i = 1, #children do if children[i]:IsA("BasePart") then print("script ran") break --here end end
If you put break before the print, it would exit the loop first, so nothing would be printed.