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

Why doesnt my tool saving script work when you rejoin the game?

Asked by 7 years ago

When I leave with a tool in my inventory and join back it simply does not give me the tool

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) 
0
Funny I have the same script and am having the same problem lol CrazyRoblots 13 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Okay so this answer is a bit easier than I originally thought. I was using this script also, a friend of mine originally wrote it and I was having the same problem as you.I was driving myself crazy trying to figure out what was going wrong and why it wouldn't save tools upon coming back into the game.

What I figured out was that I had API services enabled in Roblox Studio and for some reason or another it was messing with the datastore whenever I went into studio and edited the script or played it in studio. After I unchecked enable API services it started working 100% better.

I hope this helps you. I know it helped me.

Ad

Answer this question