Choosing the right loop

Hi all! Thanks for reading in advance.

It’s a really simple question I have, but what type of loop should I use if I want to loop through a model and change every part named ‘Colour’ to a different colour. If you have any idea, let me know and show an example because I’m not too sure on loops.

Try a generic for loop using the ipairs iterator, it’s cleaner than a numerical one and comparably (by insignificant difference) faster too.

for _, object in ipairs(model:GetDescendants()) do
  if object.Name == "Colour" then
    object.BrickColor = BrickColor.new("Bright red");
  end;
end;
1 Like