Why Does This Not Work? Trying to Change a Brick Color Of a Model I fixed my self so there is no need to choose an Answer
doors = script.Parent:GetChildren()
doors.BrickColor = BrickColor.new("Bright red")
Why Does This Not Work? Trying to Change a Brick Color Of a Model I fixed my self so there is no need to choose an Answer
doors = script.Parent:GetChildren()
doors.BrickColor = BrickColor.new("Bright red")
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 ith 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:
for i = 1, #bricks do
local brick = bricks[i]
brick.BrickColor = BrickColor.new("Bright red")
end
There are other iterators defined that make this a little shorter/semantic:
for i, brick in pairs(bricks) do -- Figure out `brick` automatically
brick.BrickColor = BrickColor.new("Bright red")
end
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:
for i, brick in pairs(bricks) do
if brick:IsA("BasePart") then
brick.BrickColor = BrickColor.new("Bright red")
end
end
Is the syntax corrected like
door.BrickColor = BrickColor.new("Cyan")
example??
So i have an idea ,so lets asume the brick is in workspace you could do this
local brick = game.Workspace.Brick
brick.BrickColor = BrickColor.new("Bright Red")
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Hey I just wrote a long answer on this but it didn't post? Really? I spent 10 minutes on my answer. Might want to report this.
It's caused by the thread being renamed. I have a practice of pasting whatever I wrote int a textfile before pressing submit.