function SaveData(Player)
local Items = {}
for i,Item in ipairs(Player.Backpack:GetChildren()) do
if game.ReplicatedStorage:FindFirstChild(Item.Name) ~= nil then
if game.ReplicatedStorage[Item.Name]:IsA("Tool") then
table.insert(Items, Item.Name)
end
end
end
PlayersItems:SetAsync(Player.UserId, Items)
end
This does not check for the items that are either dropped or consumed by the player. And I'm not sure how to remove items when the player gets rid of them.
Moderator note: Please format your Lua code with the lua block code button.

1 comment
Please format your code with the Lua button so your code is easier to read!