Ad
Log in to vote
0

How do i color a whole model within a script?

Asked by 7 days 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 7 days ago
Edited 7 days 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
7 days ago
for i,v in pairs(workspace.Model:GetChildren()) do
    if v:IsA("BasePart") then
        v.BrickColor = BrickColor.Red()
    end
end

Answer this question