How can I check if an object has children in it?
✓ ANSWER ACCEPTED
How to check if an object has children?
1 answer
✓ Accepted answer
You could create a table of the objects children by using the GetChildren() method, and then see if the table has more than 0 values...Which would mean there is children
EXAMPLE(lets say you want to figure out if a part named "Part" in the workspace has children):
local part = workspace.Part
partTable = part:GetChildren()
if #partTable >0 then
print("Object has at least one child")
end
2 comments
0
thx
0
Lol since when did objects have children? That's a joke.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Depends what you're trying to do...there's GetChildren(), DescendantAdded, etc.
If #Object:GetChildren() > 0 than the object has children. print( #object:GetChildren() > 0 and "Object has children" or "Object does not have children" ) --> 'object' is pseudo-code.