LocalPlayer.Backpack returns empty table!

I am trying to write a gun system, in which a single client script handles all of the input and gun logic.

Everytime I try to access the backpack via a client script IT WONT SHOW THE CHILDREN!

I’ve tried everything, from waiting for the child, finding first child (+ of class), delaying the script, waiting until LocalPlayer.Backpack ~= nil EVERYTHING, but it always returns an empty table WHEN I DO HAVE TOOLS IN IT.

local PLAYERS_SERVICE = game:GetService("Players")
local localPlayer = PLAYERS_SERVICE.LocalPlayer

local localBackpack = localPlayer:WaitForChild("Backpack")

print(localBackpack:GetChildren())
12:58:03.618  {}  -  Client - GunClient:34

It doesn’t make sense. Someone help!

try this

local PLAYERS_SERVICE = game:GetService("Players")
local localPlayer = PLAYERS_SERVICE.LocalPlayer

local localBackpack = localPlayer:WaitForChild("Backpack")

local Tools = {}

for i,v in pairs(localBackpack:GetChildren()) do
table.insert(i,Tools)
end
print(table.unpack(Tools))

It’s most likely because the script loads in before the tools are loaded in. You’re going to have to add another wait.

Prints an empty value.

13:20:42.770    -  Client - GunClient:40

try to change i into v that should work

I’ve already tried that, in fact I decided to try it again, waited 40 seconds before trying to get the children and still 13:22:25.430 {} - Client - GunClient:44

You can add in a remote so

local repS = game:GetService('ReplicatedStorage')

reps:WaitForChild('Loaded').OnClientEvent:Connect(function())
       local backpack = game.Players.LocalPlayer.Backpack
end

then call the remote on the server

I already fixed that and that was the result.

That’s pretty weird. I’ll do some testing and see if it works the same for me too.

It worked for me.
image

Could you show how you give the players the tools?

Can’t seem to get this to work.

-- Server
game.Loaded:Connect(function()
	game.ReplicatedStorage.LOADED:FireClient(game.Players["tannnxr"])	
end)
-- Client
GAME_LOADED.OnClientEvent:Connect(function()
    local backpack = localPlayer.Backpack
	print(backpack:GetChildren())
end)

Tools are in starterpack, so I don’t give them at all, roblox does.

do

game.Players.PlayerAdded:Connect(function(player))

game.ReplicatedStorage.LOADED:FireClient(player)

end

Yep I did that too and it didn’t work

can i see if it errors or what it outputs

It outputs literally nothing, not even with the print statement I have.

can i see your entire local script?

I got it to work somehow, all I did was add some print statements, i honestly don’t know what’s going on.

Ok well i suggest you try figure out how it works so u can reuse it