So in my script I want to get the children (or children's children) of a model which you put on separately which can have a random number of parts, and when you press a button those parts' transparency will become 1. The closest kind of technique to getting the children of an object is :GetDescendants, I use that over GetChildren because its easier to script in. I want to put the :GetDescendants into a function but the only way which the Wiki tells you to do it is by making a script like this.
for index, descendant in pairs(descendants1) do descendants1.transparency = 1 end for index, descendant in pairs(descendants2) do descendants2.transparency = 1 end for index, descendant in pairs(descendants3) do descendants3.transparency = 1 end
In summary, I want to put that in a function and make all the children of a model become invisible by using a script.
OK so I'm doing something similar but here is what id recommend trying.
for i,v in pairs(script.parent) do if v:IsA("Part") then v.Transparency = 0 else print'not needed' end end
it is saying that if v is a part it will make it transparent. If it isn't it will print 'not needed'. Make sure to accept answer if this helps. Good luck!