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

how to make ALL parts of a model fully tranparent?

i don't want to go through each and every part and make it transparent. Can someone help me?~~~~~~~~~~~~~~~~~ local model = workspace.Model


3 answers

✓ Accepted answer
local model = workspace.Model
for i,v in pairs(model:GetChildren()) do
if v:IsA("Part") then
v.Transparency = 1
end
end
end

it goes through all children until no more children

2 comments

0

or you could use GetDescendants to go through everything in the model

0

true

I will expand on KDarren12 answer, hope you don't mind mate :) IsA("Part") will not detect mesh parts (R16 for example). You should use IsA("BasePart") instead. Also if your model contains decals they will not be made transparent. Finally children of the model may have their own children and they will be omitted by the loop. Use GetDescendants() to avoid that:

local model = workspace.Model

for i,v in pairs(model:GetDescendants()) do
	if v:IsA("BasePart") or v:IsA("Decal") then
		v.Transparency = 1
	end
end

If by any chance you are making characters transparent, changing them back needs one more consideration. A part called HumanoidRootPart is meant to be transparent:

--reverse process
for i,v in pairs(model:GetDescendants()) do
	if (v:IsA("BasePart") or v:IsA("Decal")) and v.Name ~= "HumanoidRootPart" then
		v.Transparency = 0
	end
end

Have a nice scripting session

1 comment

0

dont mind at all

Your best bet would be to loop through the descendants of the model then check if they're of class BasePart (so unions and such are affected). This is better than looping through the children because the children of any folders, submodels, etc will also be indexed. Here's how you would do that:

local model = workspace.Model
for _, v in ipairs(model:GetDescendants()) do
	if v:IsA("BasePart") then
		v.Transparency = 1
	end
end

I'm not sure what you're trying to do, but it might be a better choice to simply move the model ReplicatedStorage if you're simply trying to remove it from the game temporarily.

If my answer solved your problem please don't forget to upvote and accept it.

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