Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Datastore only loads/saves the tools I have sometimes?

Asked by 13 days ago
local service = game:GetService("DataStoreService")
local datastore = service:GetDataStore("lolaaaa1uh9")
local toolstosave = { }

game.Players.PlayerAdded:Connect(function(Player)
    if datastore:GetAsync(Player.userId) then
        for i, v in pairs(datastore:GetAsync(Player.userId)) do
            print(v)
        end
    end
end)



game.Players.PlayerRemoving:Connect(function(Player)
    local toolstosave = { }
    for i, v in pairs(Player.Backpack:GetChildren()) do
        table.insert(toolstosave, v.Name)
    end
    datastore:SetAsync(Player.userId, toolstosave)
end)

Sometimes, it does not print anything when I join, even though I left with tools. Any fix?

0
Seems to me like your code crashes, I have no idea as to why this is happening, but maybe experiment with a wait function possibly before the tools load in. BryanFehr 82 — 13d
0
All datastore calls are able to error. hiimgoodpack 1851 — 13d

Answer this question