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 4 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 4 years ago
Edited 4 years ago

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

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

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
4 years ago
1for i,v in pairs(workspace.Model:GetChildren()) do
2    if v:IsA("BasePart") then
3        v.BrickColor = BrickColor.Red()
4    end
5end

Answer this question