Hi,
Had a look around for similar posts, but haven’t found too much similar to my situation.
I have about 3/4 datastores in my game, some longer than others, and theres a very rare bug in which every single datastore for one particular player will wipe. For reference when the game had been launched for about a day and a half, one person complained of all data resetting. The first time I experienced this issue, I looked into the problem of using SetAsync and found using UpdateAsync was better for data loss, however it didn’t yield much improvement.
Other than me possibly setting up UpdateAsync wrong (Although im pretty sure its right as data loads and saves correctly majority of the tiem), does anyone have any ideas that could be causing this? Il attach below the relevant UpdateAsync code of my level saving script.
local function SavePlayerData(player)
local success, errormsg = pcall(function()
local SaveData = {}
for i, stats in pairs(player.stats:GetChildren()) do
SaveData[stats.Name] = stats.Value
end
SaveDataStore:UpdateAsync(player.UserId, function()
return SaveData
end)
end)
if not success then
return errormsg
end
end
Players.PlayerRemoving:Connect(function(player)
local errormsg = SavePlayerData(player)
if errormsg then
warn(errormsg)
end
end)
game:BindToClose(function()
for i, player in pairs(Players:GetPlayers()) do
local errormsg = SavePlayerData(player)
if errormsg then
warn(errormsg)
end
end
wait(2)
end)
Thanks in advance