Is there a way you can select a child with doing .ChildName. This would be useful if you do not know the child name but you know there is only one child.
You can get all of the children of a model using :GetChildren()
. This returns a list.
If you're sure there's only one, you can just get the first thing in that list.
local model = ..... something something ..... local children = model:GetChildren() assert(#children == 1) -- assert that there is only one child local theOneChild = children[1]
Ultimately you could use the :GetChildren() command and then use the for i,v in pairs do()
command.
For this, you would want to specify the parent's location. For example:
local part = game.Workspace.Part:GetChildren for i,v in pairs(part) do v.Name = "hi" end
This code will rename the part that that is under the parent (game.Workspace.Part
). The :GetChildren() command looks under the parent that you specify, in this case, the Part in the workspace. The command will then give a table showing all the parts, and you can use the for i,v in pairs() do
command to 'decode' the table to edit the properties of the children. Since you are only wanting to use 1 child, the script will automatically stop after all the children have been edited.
Hope this answers your question!