DataStore2 not saving data every time

DataStore2 is not always saving users’ data on leave. Some players have their data reverted to an older version, or are reverted to having no data at all.

Here’s an example of how I’m using DataStore2:

local rs = game:GetService("ReplicatedStorage")
local DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
local SendMoneyEvent = rs.SendMoney
local SendWeaponsEvent = rs.SendWeapons
local PurchaseRequest = rs.PurchaseRequest

game:GetService("Players").PlayerAdded:Connect(function(player)
    local userWallet = DataStore2("UserWallet", player)
    local userWeapons = DataStore2("UserWeapons", player)

    local function sendUserMoney(value)
        SendMoneyEvent:FireClient(player, value)
    end
    sendUserMoney(userWallet:Get(5000))
    userWallet:OnUpdate(sendUserMoney)

    local function sendUserWeapons(value)
        SendWeaponsEvent:FireClient(player, value)
    end
    sendUserWeapons(userWeapons:Get({}))
    userWeapons:OnUpdate(sendUserWeapons)
end)

-- An example of how data would change, for example, when purchasing a weapon:
function PurchaseRequest.OnServerInvoke(player, requestData)
    if requestData.WeaponID then
        -- Just pretend I check they have enough money here lol, the point is the userWeapons store
        local userWeapons = DataStore2("UserWeapons", player)
        local currentGuns = userWeapons:Get({})

        currentGuns[requestData.WeaponID] = {Skin = "Epic", Effect = "Sparkle"}
        userWeapons:Set(currentGuns)
    end
end

Should I be using DataStore2.Combine? Should I be saving anything on the player’s leave? As far as I know, DataStore2 already does this automatically. We were launching a huge update with the use of DataStore2, but it’s halted due to this complication.

A shutdown isn’t required for this data loss to happen. All that needs to happen is a server switch quickly after updating your data, and the data update is no longer there.

Any ideas? Thanks in advance for any help.

EDIT: Right after releasing this “big update” I spoke of with DataStore2, I noticed that the server output was flooded with datastore queue notices. I’m not sure if this is related to that, but it seems most datastore requests made it through just fine.

EDIT 2: Could this be behavior of a player joining before their data was saved from a previous server? I’m really uncertain of how DataStore2 works in these situations as I’ve only done small-scale tests that work flawlessly. 6,000+ players suddenly seemed to have stressed it out quite a bit…

Hi… I have the same problem but when a player is switching servers, or just leave and his data doesnt save for some reason… maybe ds2 is not that good and data catching and prevent data loss and blablablabl ?