THIS SCRIPT ALWAYS WORKS BUT ITS ONLY LOADING WEAPONS WHEN U JOIN AND NOT SAVING THEM WHEN U LEAVE SO IF U GET A NEW WEAPON IS DOESNT SAVE PLS HELP ME
local ds = game:GetService("DataStoreService"):GetDataStore("ToolSave") game.Players.PlayerAdded:Connect(function(plr) local key = "id-"..plr.userId pcall(function() local tools = ds:GetAsync(key) if tools then for i,v in pairs(tools) do local tool = game.ServerStorage.Tools:FindFirstChild(v) if tool then tool:Clone().Parent = plr:WaitForChild("Backpack") tool:Clone().Parent = plr:WaitForChild("StarterGear") end end end end) end) game.Players.PlayerRemoving:Connect(function(plr) local key = "id-"..plr.userId pcall(function() local toolsToSave = {} for i,v in pairs(plr.Backpack:GetChildren()) do if v then table.insert(toolsToSave,v.Name) end end for fuck, you in pairs(plr.Character:GetChildren()) do if you.ClassName == "Tool" then table.insert(toolsToSave,you.Name) end end ds:SetAsync(key,toolsToSave) end) end)
Here's what u wanted, i didn't test it tho
local Players = game:GetService("Players") game:BindToClose(function() for i,v in pairs(Players:GetPlayers()) do local key = "id-"..v.userId pcall(function() local toolsToSave = {} for l,k in pairs(v.Backpack:GetChildren()) do if v then table.insert(toolsToSave,k.Name) end end for s, d in pairs(v.Character:GetChildren()) do if you.ClassName == "Tool" then table.insert(toolsToSave,d.Name) end end ds:SetAsync(key,toolsToSave) end end) end)