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

How would i change the transparency of every part in a Model?

i have a Model with multiple parts and i want to make every part invisible by changing their transparency, but i don't know other way to do this except for this:

local Model = workspace.Door

Model.DoorFrame.Transparency = 1
Model.Handle.Transparency = 1
Model.Part.Transparency = 1
Model.Details.Transparency = 1
--(and so on)

i know there is a different way to do this with GetChildren() but i have no clue of the rest of the code required to do that :[

1 answer

✓ Accepted answer

You can use recursion or GetDescendants:

-- Recursion

function t(obj)
   for _,v in pairs(obj:GetChildren()) do
       if v:IsA('BasePart') then
           v.Transparency = 1
       end
       t(v)
   end
end

-- GetDescendants

for _,v in pairs(obj:GetDescendants()) do
   if v:IsA('BasePart') then
       v.Transparency = 1
   end
end

1 comment

0

With GetDescendants you don't need to do any recursion.

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