Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to check if an object has children?

How can I check if an object has children in it?

2 comments

0

Depends what you're trying to do...there's GetChildren(), DescendantAdded, etc.

0

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.

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.