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

Datastore isn't saving? No error output given.

Asked by 4 years ago
local DSService = game:GetService('DataStoreService'):GetDataStore('Playerleaderstats')
game.Players.PlayerAdded:connect(function(plr)
    plr:WaitForChild("Inventory")
    plr:WaitForChild("leaderstats")
    local uniquekey = 'id-'..plr.userId

    local Store = {
    plr.leaderstats.Money.Value,
    plr.leaderstats.Crystals.Value
    }

    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        Store = GetSaved
    else
        local UpSave = {Store}
        DSService:UpdateAsync(uniquekey, UpSave)
    end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local SaveStore = {
plr.leaderstats.Money.Value,
plr.leaderstats.Crystals.Value}
DSService:SetAsync(uniquekey, SaveStore)

end)

For some reason my leaderstats does not seem to save. No error output is given either.

0
Turn on API services in game page RBLXNogin 187 — 4y
0
Api Services are already on. Andromeda0161 0 — 4y
0
Saving only upon leaving is a bad habit. Make sure you also save data during gameplay. memguy 161 — 4y
0
If I recall correctly, PlayerAdded doesn't trigger in-studio because the player joins before the script even runs. PhantomVisual 992 — 4y

Answer this question