Hi, I couldn't find a way to loop through a group. Is there a way to do it? Thanks...
EDIT:
For a cleaner way than I posted previously (no recursive looping), you can also use FindDescendantsByType(type) e.g.
for _, descendant in ipairs(script:FindDescendantsByType("Object")) do
print(descendant.name)
end
Didn't see this function earlier, my bad.
BEFORE EDIT:
There's no built-in function for this as far as I'm aware.
You can write your own function to loop recursively though using GetChildren( )
function RecursiveLoop(obj)
for _, child in ipairs(obj:GetChildren()) do
print(child.name)
RecursiveLoop(child)
end
end
local group = script:GetCustomProperty("Group"):WaitForObject()
RecursiveLoop(group)
Test Group:
Produces This Output:
Typical client/server visibility rules still apply of course - objects in a client context won't be visible if you perform this loop on the server, and vice-versa.
I was searching for GetChildren(). Thanks!