Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change multiple part colors?

Asked by 9 years ago

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

Log in to vote
-2
Answered by 9 years ago

To change a part colour, this is the best way

0
Oh, to do it for more than one part? Use a :GetChildren() or a table. WolfgangVonPrinz 0 — 9y
0
How would I use GetChildren? (I am horrible at scripting! xD) Loleydude 29 — 9y
0
Do the parts you want to change all have the same parent? dyler3 1510 — 9y
Ad
Log in to vote
2
Answered by 9 years ago

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!

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 alphawolvess 1784 — 9y
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. Perci1 4988 — 9y
0
Edited for you alphawolvess 1784 — 9y
0
Would I put this in the TextBox? Because I dont know what to edit so I can have it click. Loleydude 29 — 9y
0
Did I mention I'm horrible at scripting? XD Loleydude 29 — 9y

Answer this question