I am facing an issue that when a player enters my game and exits quickly, he loses all progress
This player had 2000 money and some power points, and when he quickly left the game and rejoin he lost all data. ( This happened because he entered quickly and the datastore was not loaded)
how do i solve this problem?
PlayerRemoving:
--some stuff above ^ (example)
for i, ld in pairs(player:FindFirstChild("leaderstats"):GetChildren()) do
Dictionary.Leaderstats[tostring(ld.Name)] = ld.Value
end
----///----
local Success, ErrorMessage = pcall(function()
StatsDataStore:SetAsync(player.UserId,Dictionary)
end)
PlayerAdded:
local Success, RecievedData = pcall(function()
return StatsDataStore:GetAsync(player.UserId)
end)
if Success and RecievedData ~= nil then
RecievedData = httpService:JSONDecode(RecievedData)
...
what i’m doing wrong?