while true do game.Workspace.BigFloor.Floor.Light.BrickColor = BrickColor.Random() wait(1.0) end
I'm trying to make a floor that will change colors every second, with the script above. However, this only changes one of the brick's color, even though all of them fall under the directory. I'm a beginning (Maybe beginning beginner? I don't know) scripter, so help is greatly appreciated.
EDIT: Sorry, I caused some confusion, I guess. I meant that one out of many parts was turning colors, and there are multiple parts surrounding the lights.
I recommend you use the GetChildren() function, which gets all of the bricks/other things inside the model. Like this:
while true do bricks = game.Workspace.BigFloor:GetChildren() for i = 1, #bricks do brick = bricks[i] brick.Light.BrickColor = BrickColor.Random() end end
im a little rusty, but this may work
For
this, you would loop through all the models children.
There are two ways to do this, both using for
loops.
model = game.Workspace.Model while wait(1) do for q=1,#model:GetChildren() do --getChildren() returns a table part = model:GetChildren()[q] --get the item in the table part.BrickColor = BrickColor.random() end end
That will make the parts flash every second.
model = game.Workspace.Model --the second way while wait(1) do for i,part in pairs(model:GetChildren()) do -- i and part are both names -- try printing i with a dictionary and with this part.BrickColor = BrickColor.random() end end
For
more information on for loops
, click on the word for
anyway in this answer. Anywhere