Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- ds:SetAsync(key,toolsToSave)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement