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

Is it possible to color a whole model?

I was wondering if it was possible to color a whole model within a script. I know you can't use BrickColor as that's only to change one brick. I've been trying to find out if there's a command like BrickColor but can't seem to find anything. Any help is appreciated.

2 answers

✓ Accepted answer

No, you can't do anything like that. But, you could use a function like this that basically continually searches the children of the model and colors the parts accordingly:

local color = BrickColor.new() -- what color you want the parts to be
local model = game.Workspace.Model -- the model you want to color

function changeColor(par)
	for _,v in pairs (par:GetChildren()) do -- loops through a model's children
		if v:IsA("BasePart") then -- checks to see if the child is part, wedge, etc
			v.BrickColor = color -- changes it's color
		end
		changeColor(v) -- the function repeats itself with the childs the parent
	end
end
changeColor(model) -- calls the function

Hopefully you can understand this script and my comments. If you need more help, be sure to comment!

Hope I helped!

~TDP

3 comments

0

The if check for the children is redundant.

0

Fixed.

0

Thanks! This helped a lot.

try ungrouping the model and color it manually?

1 comment

0

It's a car. I can't ungroup it.

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