I am having trouble with my script. I want to make everything inside a model named, "Boxes", turn to a random color each .5 seconds. But my current script only changes one part inside the model.
script.Parent.ClickDetector.MouseClick:Connect(function()
script.Parent.BrickColor = BrickColor.Green() --changes button color
for i, v in pairs(workspace.Boxes:GetChildren()) do
if i == 3 then --checks to see if i has looped 3 times (which equals the # of boxes inside the model, "Boxes")
while true do --should do a random color loop
wait(.5)
v.BrickColor = BrickColor.Random()
wait(10)
break
end
end
end
for i, v in pairs(workspace.Boxes:GetChildren()) do --changes boxes back to original color
v.BrickColor = BrickColor.new("Medium stone grey")
end
script.Parent.BrickColor = BrickColor.Red() --changes button color
end)
I'm not sure if i did the wait(10) break thing right but that's not what I'm asking y'all to fix. I'll fix that part on my own.

3 comments
Yep, I didn't do the wait thing right. If you're planning on helping me answer my question, just ignore lines 14-15, 23-29
Why would you want to put an infinite loop inside a for loop? It would just keep running the same code on the first index forever.
Cuz I'm tryna make the parts inside a model all change colors randomly in a loop after the for i, v gets the parts inside the model