✓ Accepted answer
Using commas in that way makes a tuple. red will only be given the first thing in the tuple.
This is not an appropriate case for a tuple.
It doesn't really make sense for a variable to simultaneously "be" all of those things (what would that mean? What do you do if you want to do math on such a thing? How do you separate the values later?)
You likely want a list of objects:
local frame = workspace.Frame4
local parts = { frame.Part1, frame.Part4, frame.Part7, Frame.Part10, Frame.Part13 }
parts is now a list. Changing parts (the list) won't mean anything -- a list doesn't have a color, for instance.
If you want to change all of their colors, that means you change the color of each, using a loop:
function changeColor( list, color)
for _, element in pairs(list) do
element.BrickColor = color
end
end
while true do
changeColors( parts, BrickColor.White() )
wait(0.1)
changeColors( parts, BrickColor.Green() )
wait(0.1)
changeColors( parts, BrickColor.Red() )
wait(0.1)
end
Ideally you would not list all of the parts in the definition of parts and instead would group them into a model. Then you could simply say parts = frame.Model:GetChildren().
1 comment
Thank you so much! I wanted to know why it always did it on the first one. Thanks for your explanation for this. :D