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

Is it possible to make all game parts a certain material?

Asked by 4 years ago

Title, I've tried it and kinda works. The problem is, what if a model has more models inside it?

function optimize()
    local parts = workspace:GetChildren()

    for i,v in pairs(parts)do
        if v:IsA("Model") then
            local mParts = v:GetChildren()
            for i,v in pairs(mParts) do
                if v:IsA("BasePart") then
                    v.Material = Enum.Material.SmoothPlastic
                end
            end
        elseif v:IsA("BasePart") then
            v.Material = Enum.Material.SmoothPlastic
        end
    end
end
1
Use GetDescendants for the workspace, it'll get every child even if it's inside of a model. CaptainAlien132 225 — 4y
1
use GetDescendants 0msh 333 — 4y
0
Thanks User#29320 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Try using "GetDescendants", I've used it before and I gotta say that it's a useful property to get every child even if it's inside of a model

Ad

Answer this question