I want to save the player’s tools when he leaves, but only 1 gets saved, not all the others.
Here is my script:
function PlayerDataHandler:SaveInventory(player)
for i, v in (player.Backpack:GetChildren()) do
if v:IsA("Tool") then
print(v.Name)
self:Update(player, "Inventory")
table.insert(dataTemplate.Inventory, v.Name)
end
end
end
Hey, RaxelRbx! I will try to help you out! The information Is very limited but I will try my best to guess how It’s done
Try this code:
function PlayerDataHandler:SaveInventory(player)
local inventoryData = {}
for i, v in ipairs(player.Backpack:GetChildren()) do
if v:IsA("Tool") then
print(v.Name)
table.insert(inventoryData, v.Name)
end
end
self:Update(player, "Inventory", inventoryData)
end