Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
sngnn 274 Moderation Voter
4 years ago

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

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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.

0
Thank you! sngnn 274 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question