Hello Community! I am attempting to get the children of "every" children on a Parent.
This is the script I experimented on but didn't work lol.
local folder = game:GetService("ReplicatedStorage").Folder:GetChildren()
local children = folder:GetChildren()
Thanks!
I think that what you are looking for is Instance:GetDescendants(). It will allow you to go through every child, and the children of that child and so forth.
1 | local folder = game:GetService( "ReplicatedStorage" ).Folder:GetDecendants() |
or
1 | local folder = game:GetService( "ReplicatedStorage" ).Folder:GetChildren() |
2 | local children = { } |
3 | for i, v in pairs (folder) do |
4 | table.insert(children, folder [ i ] :GetChildren()) |
5 | end |
But the first one will include any of the folder's children's children.
Use the output at all times when scripting, so you will get more detailed info on the error. Just by the code you used, I can guess your error was something like Attempt to call a nil value
1 | local folder = game:GetService( "ReplicatedStorage" ).Folder |
2 |
3 | for _, v in pairs (folder:GetDescendants()) do |
4 | print (v.Name) -- v equals all of the children and children of children in the folder. |
5 | end |
That will do it.