Children not appearing Via :GetChildren()

I’m currently trying to make a simple equip system. Apparently, the :GetChildren() method is not working. I have never encountered something like this before. When the function is ran, (which is when i press 3) It returns a nil table even though I can clearly see in the explorer tab that there are 3 tools in my player’s backpack.

elseif input.KeyCode == Enum.KeyCode.Three then
		-- Equip Melee Weapon
		print("pressed 3")
		print(backpack:GetChildren())
		for i, v in backpack:GetChildren() do
			print("checking for itemslot")
			if v:FindFirstChild("ItemSlot") then
				
				if v.ItemSlot.Value == "Melee" then
					player.Character.Humanoid:EquipTool(v)
				end
			end
		end
	end


Output:
Screenshot 2025-02-01 144049

This actually appears to be an issue with the game not detecting children of Backpack because previously I used a recursive :FindFirstChild() which also did not work, likely due to it detecting nil as a child of Backpack. Still do not understand why it is nil.

UPDATE

I found the problem which, makes absolutely no sense. Apparently defining backpack with a different variable breaks something, which again, makes absolutely no sense seeing as a variable is just a different way of stating something.

This does not work:

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

This does work:

local backpack =  game.Players.LocalPlayer.Backpack

logically, it should work both ways seeing as player and game.Players.LocalPlayer are precisely the same thing, but who knows. If you are passing by and know why this -presumably a bug- occurs please let me know.

Can you send more context?

Send more of the script too :slight_smile:

Like what is backpack defined as? Are the tools equipped? etc…

what do u have “backpack” defined as? since the client seems to think theres nothing in the backpack

wtf kind of response is this nobody said it was broken? Also not helpful why did you even reply

defined as follows. Tools are put in StarterPack and then I disabled the core Backpack GUI to create this system.

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