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?
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.