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

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

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

3 comments

1

Use GetDescendants for the workspace, it'll get every child even if it's inside of a model.

1

use GetDescendants

0

Thanks

1 answer

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

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