Cannot save more than 1 table during a datastore

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.

1 Like

Everything was fixed just randomly after changing nothing to the script. I have no clue why it started working.

Were you somehow testing in different types of game sessions, such as a studio test, then to a game test? If not, this is weird because it’s the 2nd if not 3rd post I’ve seen in the past few hours about random datastores stopping functionality for no reason without any change.

1 Like

All of these tests were within Roblox Studio. This probably means Roblox’s servers are being weird like usual lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.