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

Whats the difference between DescendantAdded and ChildAdded?

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

✓ Accepted answer
  • 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.

1 comment

0

Thanks!

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