Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change multiple part colors?

So, I used a script:

function color()
Game.Workspace.Part.BrickColor = BrickColor.new("Really red")
end

script.Parent.MouseButton1Down:connect(color)

But I want a more simple way to change more other than cloning it and changing the part names.

2 answers

✓ Accepted answer

To change a part colour, this is the best way

3 comments

0

Oh, to do it for more than one part? Use a :GetChildren() or a table.

0

How would I use GetChildren? (I am horrible at scripting! xD)

0

Do the parts you want to change all have the same parent?

There are many ways to change multiple part colors. I will show & explain a few ways. Also, because you are changing a color w/ a GUI, you make your question a bit confusing to if you want it for just a GUI, or if you're trying to change it in-game.

  • A not so efficient way could be naming each part and doing game.Workspace.Part100.BrickColor = BrickColor.new("Black") and take forever to write your code.

  • Another way can be using the GetChildren() method in a Generic loop . You could just model all the parts together (That you want to have a color change) for it to be easier. Example:

local Model = game.Workspace.PartCollection
local Parts = Model:GetChildren()


for _, Part in pairs(Parts) do
	Children.BrickColor = BrickColor.new("Really red")
end
  • You can use a Table, but you'll end up (Maybe) using a Generic for loop to change them and the above way is much simpler. Of course you could possibly do more things with a Table!

If this helps, help me with an Up Vote and Accept!

5 comments

0

I said "Part100" as a joke because that would be the 100'th part due to their being so many you'll have to put down

0

Your second variable in the for loop, Children, doesn't really make sense since it doesn't equal anything plural -- you're only accessing one child at a time. 'child', 'part', 'brick' or other singular words would make more sense.

0

Edited for you

0

Would I put this in the TextBox? Because I dont know what to edit so I can have it click.

0

Did I mention I'm horrible at scripting? XD

This discussion is preserved as it was. New answers, comments, and votes are closed.