To understand this issue more clearly, here’s the schema of my game’s current datastore:
{
["File1"] = {};
["File2"] = {...}; --Contains many values within this table.
["File3"] = {};
["Settings"] = {};
}
Now, when all tables within this datastore are empty, and then I create a singular new save file, it works fine. However, if I try to save File1 or File2 for example, both are empty when loading them after rejoining.
Here is the function to save data once the player is added:
function GameDataHandler.SaveData(Player: Player)
if not SavingFor[Player] then
SavingFor[Player] = true;
if _G.GameData[Player] then
local Success, Error = pcall(function()
GameDataStore:SetAsync("Player_"..Player.UserId, _G.GameData[Player]);
print("SAVED GAME DATA:",_G.GameData[Player]);
end);
if not Success then
warn("Coudln't save data for: "..Player.Name);
return;
end;
_G.GameData[Player] = nil;
end;
SavingFor[Player] = nil;
end;
end;
The current data is also only around 4KB, so the issue definitely isn’t an issue with data limits.
The biggest culprit noticed was that GameDataStore:SetAsync() yields forever, not allowing any further execution after that line. But remember, this only happens if 2 of the save files are trying to be created/saved at once.