What im talking about is is it possible for a script to detect all children from a model. For example: Lets say the code is FindChildren
local childs = script.Parent.FindChildren childs.Transparency = 1 childs.canCollide = true
So now, all the children from the Model now have a transparency of 1 and Collision. Is there another feature for that?
There is a function for this already.
local children = script.Parent:GetChildren(); -- This is gathering all of the children in script.Parent into an array (i.e., children = {script, textLabel, etc.}) for i,v in pairs(children) do -- The for loop is used to sort through the array in order and we can manipulate parts as need be. The variable i shows the number in the array that the entry is, whereas the v variable is for the part itself. Given how v is an object we can't just do print(v) we would need to do print(v.Name) to see what v's real name is. v.Transparency = 1; -- Setting the transparency of object v to 1 v.CanCollide = true; -- Setting it so that v CanCollide with other blocks end;
This will make every part in the scripts parent so they can collide and they are invisible. If you are looking for a specific part you can use this function
local child = script.Parent:FindFirstChild("Sphere"); -- This finds the first child in script.Parent with the name of "Sphere". Now you can do whatever you want to it.
If this helps, please accept this answer.
Yes. You tried, and that's good. However, the correct function to use is :GetChildren(). This will return an array - or table - of children.
To find a specific child, you can use :FindFirstChild(name). If the child is not found, it will return nil
.