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

How do i color a whole model within a script?

Asked by 3 years ago

Hey there, i was wondering how do i color a whole model within a script?

Please tell me where the script should we, what type of script. And the script, thank you!!

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I'm super noob at scripting but I think you can do :

local model = script.Parent
local children = model:GetDescendants() --first we get the descendants
for i , v in pairs(children) do --we loop through them
    if v:IsA("BasePart") then -- we check if it's a part
        v.Color = color3.new(1,0,0) -- we give them a color (red in this case)
    end
end

There we go. Put it as the model's children Use a script (not a localscript nor a modulescript)

Note : a basepart is a class that contains everything that is a "part" (part,meshpart,wedgepart,terrain, and many more). You can go check this in the developper hub. I hoped this helped you !

Ad
Log in to vote
0
Answered by
Punctist 120
3 years ago
for i,v in pairs(workspace.Model:GetChildren()) do
    if v:IsA("BasePart") then
        v.BrickColor = BrickColor.Red()
    end
end

Answer this question