I need to make it so that a model with 85 parts becomes completely invisible. I wanna see if there's a way to do this with only one line of code so that I don't have to type game.Workspace.MENUCHARS.BLAHBLAH.BLAHBLAH.Transparency = 1 eighty five times. I've tried blahblah = game.Workspace.menuchars.BLAHBLAH:GetChildren() and then blahblah.Transparency = 1, but it of course, didn't work.
✓ ANSWER ACCEPTED
How do you make a model with a lot of parts invisible with only one line of code?
2 answers
✓ Accepted answer
You can accomplish this with pairs
Code example:
local menuChars = game.workspace:WaitForChild("MenuChars") -- where ever your model is
for index, value in pairs(menuChars:GetChildren()) do -- loop through everything in the model
if value:IsA("BasePart") then -- make sure its a part
value.Transparency = 1 -- set transparency
end
end
Use loops, like this:
for _item in pairs(Object:GetChildren()) do
item.Transparency = 1
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
GetChildren returns an array, so you should use ipairs as it is less resource intensive.
Oh really. Never knew that. So you can do ipairs(menuChars) and it will do the same as in pairs(menuChars) while being less resource intensive?
Oh really, I never knew that. So you can do ipairs(menuChars) and it will do the same as in pairs(menuChars) while being less resource intensive?