LocalScript doesn't respond to child being added to Backpack

Hi! Trying to do a custom Hotbar for tools while encountering an issue.

My LocalScript (which is located in PlayerGui) doesn’t detect when a child is being added/removed from the backpack.

local player = game.Players.LocalPlayer
local backpack = player.Backpack

backpack.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") then
		generateButton(tool)
	end
end)
Hierarchy, unsure of it's usefulness though.

image

Any help is appreciated!

Note to self and everyone - For some reason put all functions above loops (not just infinite ones either) :confused:

You can wrap the loops in coroutines, and it would not affect the rest of the code.

1 Like