Player data saving script not working

I launched my game Obby Time on Friday. However, many players have reported data losses happening when traveling between the lobby place and the game place.

I joined the game myself today to see what’s wrong with it and saw this:

How can a table like this be over 260k characters long? And why does Roblox has to set such a limit?

local defaultPlayerData = {
	["Values"] = {
		["Coins"] = 50;
		["Gems"] = 5;
		["Wins"] = 0;

		["XpAmount"] = 0;
		["Level"] = 0;
		["Gamepasses"] = {
			["MapVote"] = false;
			["DoubleCoins"] = false;
		["Settings"] = {
			["MusicMuted"] = false;

	["Inventory"] = {
		["Trails"] = {
		["Auras"] = {
		["Accessories"] = {
		["Crates"] = {
			["CommonCrates"] = 0;
			["UncommonCrates"] = 0;
			["RareCrates"] = 0;
			["EpicCrates"] = 0;
			["MythicalCrates"] = 0;
			["LegendaryCrates"] = 0;

		["Equipped"] = {
			["Trail"] = nil;
			["Aura"] = nil;
			["Accessory1"] = nil;
			["Accessory2"] = nil;
			["Accessory3"] = nil;

	["Promocodes"] = {
		["UsedPromocodes"] = {

I created a gist of the player data saving script, if you want to see the whole script.

I have already tried splitting the table into multiple tables saved with different keys but that just eats up the quota.

So, what here isn’t working right? And how could I fix it ASAP to prevent future data losses?


You are basically trying to store too much information, every single character you use in the table adds to the 260000 character limit (this limit is per key). If you exceed it roblox wont save the data.

You can prevent this by making the names for the data shorter, instead of “MapVotes” you could use “MV” as an example.

I’m also not sure how you are saving the bought items of a player. If you use really long names for these, it eats up a lot of the character limit. I suggest using keys for your items like “T1” for trails, in a module scripts you could then store what this item exactly is.

If you want to check how big a data file is you can use:
This will show the amount of characters a data file is.

1 Like

If they are exceeding the character limit, a solution is almost certainly not to make the names shorter. This is just a way to maybe buy yourself 2 more seconds before the issue happens again.

Just do # instead of string.length. string.length isn’t even a real function. Also, the names probably don’t even take up 1000 characters, so I don’t think that’s going to help very much with the 260,000 character limit.

Edit: Yeah, the text between quotes (including the quotes themselves) take up a total of 321 characters. That’s not going to be a significant enough fix.


Also just wanted to clarify that it’s not 260k characters for all the player’s data, just 260k characters per key. Which is confusing me, how did that table manage to exceed the limit? It might not even be close to a thousand. This is indeed strange and it is a good idea for the OP to print the length of the JSON’d data.

I printed out the JSONEncoded length of the data I was trying to save and wasn’t even close to 260k. Guess how many characters? 597, not even close to that.

Yeah, it was obvious that this was no way near the thousands, this is super strange.

I was just trying to give tips on how to optimise this as it isn’t really an efficient way of storing data in my opinion. I just try to shorten keys if possible as these just take up extra characters.

Oops I got confused there for a second. I corrected it so it uses .len which is a real function. Of course this wouldn’t be enough characters to exceed the limit, I assumed he used a really inefficient way to store which items a player bought. He didn’t really provide any detail on how exactly he does this. If this is done inefficiently it could eat up a lot of characters. This might not be a problem if you own 2 items but once you have 100’s of items this could be a problem.

There aren’t that many items in game either. And still saying it’s over 260k. Roblox should remove all limitations like that, they just suck and do nothing good.

I might have found something. The promocode script handling promocode “Viper” for the ToH YouTuber S_Viper might be at fault here because:

So, I found the solution.