Script doesn't detect when child added

I need the script to detect when a child is added to player’s backpack.

The script doesn’t register it no matter if it Is in a While loop or not or if I use descendant added or child added (pic below)

Zrzut ekranu 2023-07-31 o 15.22.41

First a while loop stops the bottom code from executing.

its an example of what I tried, they all aren’t in the same code

You may want to add a WaitForChild() statement to guarantee that the Instance had been replicated on both server and client, as stated in the Docs for .ChildAdded().

So thing.ChildAdded():WaitForChild()?

I think so Developers forgive me if I’m wrong, just have to add the string to check for the Instance’s name.

I can’t really check for the name because I need it to detect anything that is added, maybe a class would work?

If you just need it to detect something, I would suggest making .ChildAdded() into a function, and just writing your code inside the function to check for the Instance’s class:

thing.ChildAdded:Connect(function(newChild)
     if newChild:IsA(“InsertType”) then
       -- Code here.
     end
end)

Also, please ignore the WaitForChild() part, I think that was a way to check for Descendants, since getting the Event will automatically return the parameter, which is the Instance that just got added. My bad there.

doesn’t work, nothing shows up (tried to print)

Did you change InsertType? If so, can I see the hierarchy of the Script on the game’s Explorer?

How can I do it? character limit

I meant for you to change InsertType to the class which you wanted to check the Instance for.


Showing the hierarchy of the Script just means showing where exactly it’s located on the game’s Explorer tab.

Yes I changed it to tool type limit

Well, can you perhaps take a screenshot of where you placed the Script at?

Zrzut ekranu 2023-07-31 o 15.54.18

Can you take a picture of where the script is stored on the Explorer Window?

its in server script service. limit

You might want to try and remove

if child:IsA(“Tool”) then

Line, since everything that goes into the Player’s Backpack is a tool. Try that and see if it helps debug the script.


still nothing

This is because it is a server script and you’re adding a tool on the player’s client. This will not replicate.