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

My Ordered Data Store Isn't Saving the Data?

Asked by
Borrahh 265 Moderation Voter
3 years ago

Hey everyone, this is my first time using ordered data store. When I am trying to save the data, I get the Warn Data Couldn't be saved I don't know what im doing wrong?

 local theStatsDataStore = game:GetService("DataStoreService"):GetOrderedDataStore("theStats")

game.Players.PlayerAdded:Connect(function(player)
    local Exp = player:WaitForChild("theStats").Exp
    local Levels = player:WaitForChild("theStats").Levels

    local theData
    local success, theError = pcall(function()
        theData = theStatsDataStore:GetAsync(player.UserId)
    end)

    if success then
        if theData ~= nil then
            Exp.Value = theData[1]
            Levels.Value = theData[2]
        else
            print("No Data")
        end
    else
        warn("Data couldn't be loaded")
    end
end)



-- save the data
game.Players.PlayerRemoving:Connect(function(player)
    local tableToSave = {}
    table.insert(tableToSave, player.theStats.Exp.Value)
    table.insert(tableToSave, player.theStats.Levels.Value)
    local success, theError = pcall(function()
        theStatsDataStore:SetAsync(player.UserId, tableToSave)
    end)

    if success then
        print("Data Succesfuly Saved!")
    else
        warn("Data couldn't be saved")
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Is your error like a warn that prints something like "Further requests will be dropped"?

0
Not the one you set, but are you getting that? Itz_Visually 17 — 3y
0
I am only getting the one that i set, not the furthers requests will be dropped Borrahh 265 — 3y
Ad

Answer this question