Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What Did I Do Wrong In This ToolSaver Script? That Should Save Tools

so my tool save is not working and idk why script is here

local dss = game:GetService("DataStoreService")
local toolsDS = dss:GetDataStore("ToolsData3")
 
local toolsFolder = game.ReplicatedStorage:WaitForChild('Tools')
 
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)

so the tools dont save AND it does not give me any error thanks for reading!!

1 answer

Have you tried doing this?

  • tell me if this works since i'm not good with DataStoreService!
local unpackTools = {}
local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools")

table.insert(unpackTools, toolsSaved)

    for i, toolSaved in pairs(unpackTools) do

        if toolsFolder:FindFirstChild(toolSaved) then

            toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
            toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear
      end
end

3 comments

0

Ok tnx i just woke up so let me try later

0

You mean try the whole script you gave?

0

Like i mean should i replace my Whole Scriot with that?or replace with a certain line?

This discussion is preserved as it was. New answers, comments, and votes are closed.