So, I followed a yt tutorial on how to make a tool saving script. The first time I tried loading the tools it worked normally, but the 2nd time I played the game the script broke. Does anybody know how to fix this? Here's the script:
local dss = game:GetService("DataStoreService") local toolsDS = dss:GetDataStore("ToolsData") local toolsFolder = game.ServerStorage.ToolsFolder game.Players.PlayerAdded:Connect(function(plr) local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {} for i, toolSaved in pairs(toolsSaved) do if toolsFolder:FindFirstChild(toolSaved) then toolsFolder[toolSaved]:Clone().Parent = plr.Backpack toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear end end plr.CharacterRemoving:Connect(function(char) char.Humanoid:UnequipTools() end) end) game.Players.PlayerRemoving:Connect(function(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 errormsg then warn(errormsg) end end) game:BindToClose(function() local players = game.Players:GetPlayers() for i = 1, #players do local plr = players[i] 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 errormsg then warn(errormsg) end end end)
Also, I would like to address some common questions you may ask: 1. API Services are enabled. 2. I tested it both in studio and in the real game. 3. There are no errors in the output. 4. I can tell the problem is with loading the tools because when I stop the game in the output it says "DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 178628425-tools", meaning that it saved properly.
So if anybody could help I would really appreciate it!
So, it turns out if you clone the tool from workspace, it doesn't work. If you clone the tool from the tools folder, the autosave feature works.