Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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!!

Answer this question