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

Looking for a color conversion thing...?

Hello, Im looking for a way to convert all red bricks to blue brick.

E.g All red bricks will change color to blue. Instantly.

2 comments

0

This isn't a request website.

0

No Im just wondering if I can get hints,

1 answer

✓ Accepted answer

Brick Color

The property of a part that determines it's color is called "BrickColor" and you use it to ... change the brick color yes. It takes 1 argument as either a string, enum or even a color 3 that determines the color of the part

game.Workspace.Part.BrickColor = BrickColor.new("Wheat")  -- Turns the color of the brick to "Wheat"

game.Workspace.Part.BrickColor = BrickColor.new(340)  -- This is also Wheat, but 'tis the enum

game.Workspace.Part.BrickColor = BrickColor.new(Color3.new(1, 1, 1)) -- When using Color3, roblox just picks the closest color to match that rgb value since roblox bricks use a pallet of 64 colors... I think

Heres uh uh useful list of all the color codes http://wiki.roblox.com/index.php?title=BrickColor_codes

NOW THAT UH WE CAN MAKE BRICKS PRETTY COLORS LETS GET TO THE .. vague part of your question when you say "ALL THE RED BRICKS TO BLOO"

LOOPS

I guess the best way to do this would be a loop-- a for loop.

for i, v in pairs (game.workspace:GetChildren()) do -- Get a table of everything in the workspace, or whatever place your parts are in
	if v:IsA "Part" and v.BrickColor.Name == ("Black") then -- Is this thing a Part? and is this thing Red? Or in this case black because I feel like black today.
		v.BrickColor = BrickColor.new("Wheat") -- Were the last 2 arguments true? GREAT OKAY MAKE IT WHEAT. BECAUSE I mmmmm I like wheat. Or Green if you want
	end
end

AH OKAY SO WHAT IN THE WORLD DID I JUST DO!?

I used a for loop, or generic loop whatever it is you want to call it. What the for loop does is it runs through the loop, and increments the iterator. What does that mean in this context? It's running through a table of everything in the workspace, hence "game.workspace:GetChildren()" and checking if the item is

A: A part and

B: Is it a certain color?

If both those statements are true then it changes the brick to wheat...

SO I GUESS AT THIS POINT if you want if the bricks are in a model you can just change the table argument to [MODEL LOCATION HERE]:GetChildren() and change the color or whatever other property of the brick you want changed.

Oh dear i've never written an answer this long-- people with an absurd amount of rep be merciful.

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