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

How would I use ChildAdded for the whole Workspace?

Asked by 5 years ago

I want to know how I can do childadded for the whole workspace

Like If anything just inside the workspace gets added

I wanna print it

2 answers

Log in to vote
1
Answered by 5 years ago

You're looking for the DescendantAdded event!

game.Workspace.DescendantAdded:Connect(function(descendant)
    print(descendant:GetFullName())
end)
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

this will fire when an object is added into workspace

game.workspace.ChildAdded:Connect(function(object)
    print(object.Name)
end)

If you want to check if a specific instance is added, then add an if statement using :IsA

game.workspace.ChildAdded:Connect(function(object)
    if object:IsA('[Whatever instance you want]') then --
        -- run this code
    end
end)

you can also check the object's name if you are looking to for very specific things

game.workspace.ChildAdded:Connect(function(object)
    if object.Name == '[Any parts name that you are looking for]' then --
        -- run this code
    end
end)

Answer this question