So I've got many bricks in different models called "Lamp2". How do i change color of all of them to another color?
Model1 { Lamp2 Brick Brick } Model2 { Lamp2 Brick Brick }
Would there be a way to change all of the colors of them?
EDIT: A bit of an explanation I have a button in workspace and i have several other models in workspace. When I press the button I'd like to make all bricks called "Lamp2" to change color to say "Bright red". So when the player pushes the button I want to change the brick called "Lamp2" inside of different models.
If all of these lamps are in a model
, you can iterate over all children of workspace
and if Lamp2 exist as a child, change the color.
local children = workspace:GetChildren() for idx = 1, #children do local child = children[idx] if child:IsA("Model") then -- child is a model local lamp = child:FindFirstChild("Lamp2") if lamp then -- lamp exists lamp.Color = blah -- new color here end end end
In short, for every child of workspace
: if it's a Model
and a child named Lamp2 exists: Change the color of Lamp2
An easier way is just looking up Lamp2 in workspace and selecting them all and choosing the brick color :)