#ChildAdded not working

1 messages · Page 1 of 1 (latest)

west mural
#
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.Backpack.ChildAdded:Connect(function(child)
        print(child)
    end)
end)```When I go on server view and add a tool into my backpack it doesn't print anything..
light gust
#

u forget the get characteradded and character's backpack

#

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local backpack = player:FindFirstChild("Backpack")
if backpack then
backpack.ChildAdded:Connect(function(child)
print("tool added to backpack: " .. child.Name)
end)
end
end)
end)

west mural
#

Thank you, this worked

#

Why do you have to do this tho?

#

Shouldn't it just say that "Backpack" is nil if you try to index it to early?

light gust
#

because the Backpack doesnt exist until the character spawns

light gust
west mural
#

Alright, well thank you

vagrant adder
vagrant adder