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

Whats the difference between DescendantAdded and ChildAdded?

Asked by
Prioxis 673 Moderation Voter
8 years ago

So I noticed there's not much of a difference between Descendant added and Child Added But just in case can someone tell me the difference in function say I want to check the workspace if an object was added which would be the better one to use?

This is my current script that checks the workspace if a script is added

game.Workspace.ChildAdded:connect(function(instance)
    if instance.ClassName == "Script" then
        instance:Destroy()
    elseif instance.ClassName == "LocalScript" then
        instance:Destroy()
    end
end)

would it be better to keep it at ChildAdded or switch it to DescendantAdded?

1 answer

Log in to vote
3
Answered by 8 years ago
  • ChildAdded
    fires when something is added as an immediate child of the object. In your case, if something goes this.Parent = workspace, ChildAdded will be fired.

  • DescendantAdded
    fires when something is added as a descendant of the object. For example, if something goes this.Parent = workspace.Something.SomethingElse, DescendantAdded will be fired (But ChildAdded will not). It is worth noting that DescendantAdded will fire in all cases when ChildAdded will.

0
Thanks! Prioxis 673 — 8y
Ad

Answer this question