Hello, I followed this tutorial https://www.youtube.com/watch?v=PZp9nfuqPpQ on how to save items when players leave, but it won't work? Does anyone know why? Thanks. :)
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)