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

What is the difference between :GetDescendants() and :GetChildren()?

I don't want to get confused while making a script. Is there a difference, and if so, what is the difference?

2 answers

✓ Accepted answer

GetChildren() returns an array (Lua Table with natural number indices) of all the immediate (first-generation) children of the Instance you pass it. Only things for which the passed-in Instance is their Parent.

GetDescendants() recursively visits all the children, childrens' children, childrens' childrens' children, etc... every single Instance in the hierarchy under the passed-in argument Instance, and returns references to all of them in an array.

1 comment

0

Thank you!

:GetChildren() returns the first children of the object or model, :GetDescendants() returns all children

This discussion is preserved as it was. New answers, comments, and votes are closed.