First, my code:
local DATASTORESERVICE = game:GetService("DataStoreService")
local toolStore = DATASTORESERVICE:GetDataStore("-tools")
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
local tools = {}
for _,v in pairs(player.Backpack:GetChildren()) do
table.insert(tools,1,v)
print("Saving: "..v.Name)
end
for _,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then
table.insert(tools,1,v)
print("Saving: "..v.Name)
break
end
end
local own = {}
for i,v in pairs(game.ServerStorage:GetChildren()) do
if tools:FindFirstChild(v.Name) then
table.insert(own,i,true)
else
table.insert(own,i,false)
end
end
toolStore:SetAsync("-tools"..player.UserId,own)
end)
end)
game.Players.PlayerAdded:Connect(function(player)
local success,value = pcall(function()
local tools = toolStore:GetAsync("-tools"..player.UserId)
end)
if value ~= nil then
local own = value
for i,v in pairs(own) do
if v == true then
local tool = game.ServerStorage:GetChildren()[i]:Clone()
tool.Parent = player.Backpack
end
end
end
end)
This is all 1 script. I am trying to store which weapons a user leaves the game with, so that when they re-enter the game, they have those same weapons.
Currently, it seems to save just fine. I have tried saving a string, and it ends up returning an empty table when I use GetAsync.
Why does this not work, or what would I need to do to make this work?
If you have any further questions, please ask them. I really need to get this fixed.

2 comments
It seems that Line 10 is giving you errors as the character is no longer in the game when it runs. What I recommend that you do is remove the pcall and run the code through until you get it to function then add it in afterwords.
I am going to change my entire outlook on how I save the tools. Thank you though.