doors
is a list of Bricks.
Lists don't have BrickColors, so changing the BrickColor of a list won't do anything.
You want to set the .BrickColor
of the elements of the list, that is, of the bricks listed in the list.
You can get the i
th element of a list like this: list[i]
. There are #list
things in a list, so we can use a loop to have i
go from 1
to #list
:
2 | local brick = bricks [ i ] |
3 | brick.BrickColor = BrickColor.new( "Bright red" ) |
There are other iterators defined that make this a little shorter/semantic:
1 | for i, brick in pairs (bricks) do |
2 | brick.BrickColor = BrickColor.new( "Bright red" ) |
You want to be careful, though. If there are other things in the model that aren't Parts, this will error when you try to set their .BrickColor
. We should add a check to be sure:
1 | for i, brick in pairs (bricks) do |
2 | if brick:IsA( "BasePart" ) then |
3 | brick.BrickColor = BrickColor.new( "Bright red" ) |