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

Is it possible to color a whole model?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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

0
The if check for the children is redundant. User#6546 35 — 8y
0
Fixed. TheDeadlyPanther 2460 — 8y
0
Thanks! This helped a lot. toughjohncena1256 57 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

try ungrouping the model and color it manually?

0
It's a car. I can't ungroup it. toughjohncena1256 57 — 8y

Answer this question