I am currently trying to make the tools in the player inventory save, so when they die it won’t just go away. But I am encountering an issue where if player:LoadCharacter happens the tools won’t come back.
So naturally, I tried to check why can’t Player.CharacterRemoving work, I printed the numbers of children in the Backpack and it was 0, even though I had 2 tools in my inventory.
When humanoid dies and respawns, tools come back as intended.
Video featuring the function:
But when load character it does not.
Video featuring the problem:
Printed:
![]()
The code I am using:
local function OnPlayerAdded(Player)
local SavedTools = {}
local function SaveTools(Character)
-- Save all tools from Backpack
for _, Tool in pairs(Player.Backpack:GetChildren()) do
if Tool:IsA("Tool") then
table.insert(SavedTools, Tool:Clone())
end
end
-- Save any tool currently equipped
for _, Tool in pairs(Character:GetChildren()) do
if Tool:IsA("Tool") then
table.insert(SavedTools, Tool:Clone())
end
end
end
local function OnCharacterAdded(Character)
-- Restore saved tools
for _, Tool in pairs(SavedTools) do
Tool.Parent = Player.Backpack
end
SavedTools = {}
-- Connect Died event to save tools on death
Character:WaitForChild("Humanoid").Died:Connect(function()
SaveTools(Character)
end)
Player.CharacterRemoving:Connect(function()
print("Backpack children:", #Player.Backpack:GetChildren())
end)
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
-- Handle players who are already in the game
for _, Player in pairs(Players:GetPlayers()) do
OnPlayerAdded(Player)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
Any help is appreciated! ![]()