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

How do i color a whole model within a script?

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

✓ Accepted answer

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 !

for i,v in pairs(workspace.Model:GetChildren()) do
    if v:IsA("BasePart") then
        v.BrickColor = BrickColor.Red()
    end
end

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