Backpack.ChildAdded and ChildRemoved not working?

  1. What do you want to achieve?
    I’m working on a custom inventory system.

  2. What is the issue?
    It doesn’t seem to update whenever I pick up or drop a tool.

  3. What solutions have you tried so far?
    This is my code

function updateInv()
	print'update aaaaaaaaa rofls' -- Purely for scientific purposes
	BackpackFrame:ClearAllChildren() -- removes previous buttons
	script.InvLayout:Clone().Parent = BackpackFrame- -- adds a GuiGridLayout
	local tools = Player.Backpack:GetChildren() -- Gets all the tools
	tools[#tools+1] = Char:FindFirstChildOfClass('Tool') -- Gets the tools inside the character
	for i,v in pairs(tools) do -- for all these tools
		if v:IsA('Tool') then -- if it really is a tool
			local item = script.BackpackItem:Clone() -- create a button for it
			item.Parent = BackpackFrame -- parent the button to the frame
			item.ImageLabel.Image = v.TextureId -- give the button the tool's image
		end
	end
end

updateInv()
Player:WaitForChild('Backpack') -- wait for the backpack
Player.Backpack.ChildAdded:connect(updateInv) -- call this function every time something is added to the backpack
Player.Backpack.ChildRemoved:connect(updateInv) -- call this function every time something is removed from the backpack
Player.Backpack.DescendantAdded:connect(updateInv) -- aaaaaaaaa
Player.Backpack.DescendantRemoving:connect(updateInv) -- imgettingdesperate

y it no update?
i no understand

I’m probably doing something really stupid or something.
Can someone enlighten me?

EDITS:
Commented code so it’s easier to understand
Reduced a thingy so it’s one line for better readability

Backpack instance is destroyed each time a character is added and a new backpack is created. I think that this might be the issue and that’s why you lose these event connections. I suggest to get the backpack instance and create event connections each time a character is added.

Player.CharacterAdded:Connect(function()
    local bp = Player:WaitForChild('Backpack')
    bp.ChildAdded:connect(updateInv)
    bp.ChildRemoved:connect(updateInv)
    bp.DescendantAdded:connect(updateInv)
    bp.DescendantRemoving:connect(updateInv)
end)

Thanks for the response.
Sadly, this doesn’t seem to be what’s causing the problem.

local b= Player.Backpack

while wait() do
	print(b.Parent,b)
end

I tried slapping this at the end and it outputs
dispeller Backpack(x600)

That confirms that the backpack is the same backpack.

When you pickup a tool it goes instantly to the character model and does not go through backpack. I tested the code and it prints the string (line 2 of your code) when you put something into the backpack.

An equipped tool is not a child of backpack but the character model. In order for your program to detect a change you would have to pick up a tool then unequip it so it goes to backpack.