Descendants are like children, but they go all the way down the tree of children. Ancestors are like parents, but go all the way up the line of parents. If you had a model structured like so:
Model - “Tree” (parent to Workspace)
Part - “Branch” (parent to Tree)
Part - “Root” (parent to Branch)
If you had a script that said:
local tree branch = workspace.Tree:FindFirstChild("Branch")
this would return the “Branch” part. But you couldn’t do:
local tree branch = workspace.Tree:FindFirstChild("Root")
because the part named “Root” is a descendant of “Tree”. Not a direct child, but a child of a child. So instead, you could get it like this:
local tree branch = workspace.Tree:FindFirstDescendant("Root")
And this would return the part named “Root”.
you could do the same for ancestors.
TLDR a child is a child somewhere down the line of an object, rather than a direct child of an object, and same for ancestors. Ancestors are not the direct parent of an object, but somewhere up the line of parents.
Edit: The reason this is useful is because although working with ancestors/descendants can be laggy depending on what you are doing, lets say for example you wanted to make all Parts in the Workspace named “Door” have CanCollide = false.
If you made a script like so:
for _, p in pairs(workspace:GetChildren()) do
if p:IsA("BasePart") and p.Name == "Door" then
p.CanCollide = false
end
end
This would only loop for BaseParts (Parts, meshparts, etc.) that their parents were directly workspace, but if you had models in the workspace, this script wouldnt target them because they werent direct children of game.Workspace. So to fix that you could use this instead:
for _, p in pairs(workspace:GetDescendants()) do
if p:IsA("BasePart") and p.Name == "Door" then
p.CanCollide = false
end
end
Now the script would make every single Part named “Door” be able to be walked through if it was placed in the workspace, even if it was grouped in many models or folders! Although it would be more laggy, it would be the easiest and most efficient method to do this!