I did some more testing and this worked for me:
Script
local Players = game:GetService("Players")
local dss = game:GetService("DataStoreService")
local toolsDS = dss:GetDataStore("ToolsData1")
local function SaveData(plr)
local toolsOwned = {}
for i, toolInBackpack in pairs(plr.Backpack:GetChildren()) do
table.insert(toolsOwned, toolInBackpack.Name)
end
local success, errormsg = pcall(function()
toolsDS:SetAsync(plr.UserId.."-tools", toolsOwned)
end)
if success then
print("Saved data")
for i, v in pairs(toolsOwned) do
print(v)
end
elseif errormsg then
warn(errormsg)
end
end
Players.PlayerRemoving:Connect(SaveData)
game:BindToClose(function()
task.wait(3)
end)
yes, i know that you said you would do it yourself but i am determined to get the script working.