We want players to be able to earn money, and then spend that money on different cars, upgrades for those cars and equipment. However, the DataStore is sometimes reverting back to previous data that was stored. Players report buying vehicles and/or upgrades for them, only to have them not save when they leave and join another server. Players have also reported losing money. This issue seems to effect some people more than others. Some players haven’t had any trouble at all, while others frequently lose data. It also appears to be more prevalent in VIP servers.
We have tried using pcalls and BindToClose to help increase the odds of not losing data. We initially thought we fixed the issue after the latest patch, but it was only about an hour before we received more reports of players losing data. At this point it’s becoming very frustrating for not only us, but for our players, and we need to find a solution ASAP.
local dataStore = game:GetService('DataStoreService') local playerKey,inventoryKey = 'PlayerBaseData','PlayerInvBaseData' local playerStore = dataStore:GetDataStore(playerKey) local inventoryStore = dataStore:GetDataStore(inventoryKey) function savePlayerData(player) local playerDataKey = 'player '..player.UserId..' '..playerKey local playerInventoryKey = 'player '..player.UserId..' '..inventoryKey local inventorySaved,playerDataSaved,attempts = false,false,0 playerDataSaved = pcall(function() playerStore:UpdateAsync(playerDataKey,function() return playerData end) end) inventorySaved = pcall(function() inventoryStore:UpdateAsync(playerInventoryKey,function() return carData end) end) end game.Players.PlayerRemoving:connect(function(player) savePlayerData(player) end)
This isn’t all of the coding, but it’s a chunk of the main coding that handles the saving. Let me know if you need to see more.