Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is the maximum Data Store size, and how can I check how much Data I'm using?

So I have a very large table for an inventory, and I want to save to Data Stores. Aside from the table, however, I have plans to store other stuff. So I'm trying to figure out How much Data I'm storing versus How much would be left (if any). I've looked on the Wiki, but can't seem to find the info I need / don't understand whats given. All help appreciated.

4 answers

For the DataStore limits, refer to this. I don't know any ways to see how much data you're using, since I don't know of a way to index a data store. But, if you're using up too much data, you should get an error.

Ok, I may have an idea (Ik I'm replying to own answer, just hoping for some comments on this.) I found you can Encode JSON manually, and according to the wiki, "Tables are saved in JSON, which means that the encoded JSON string should not exceed the data limit" So maybe:

local tab = Inventory --Table's Name
local u = assert(LoadLibrary("RbxUtility"))
print(#u.EncodeJSON(tab))

Disclaimer: I haven't really dived into DataStore yet, so I may be misinterpreting what I've read.

That being said, I think Xduel was on the right track with manually encoding the table into JSON to check its length. However, some tinkering in Studio revealed that RbxUtility.EncodeJSON() is deprecated -- directing me to use Game:GetService("HttpService"):JSONEncode() instead. Here's some code:

--Here's a sample table of data.
local statsTable = {
	level = 348;
	money = 10110;
	class = "White Mage";
	is_in_party = true; --They always seem to be, anyway. :P
	dungeonsFinished = {
		fairyForest = true;
		clockworkTower = true;
		darkDescent = false;
	};
}

--Here's where we can figure out how much space the table occupies as a JSON encoded string.
local j = game:GetService("HttpService"):JSONEncode(statsTable);
print("JSON Encode: " .. j);
print("JSON length: " .. #j);

The length of the encoding will be about as long as you see it in the code. For this particular example, you should get the following output (or something very similar):

JSON Encode: {"dungeonsFinished":{"clockworkTower":true,"darkDescent":false,"fairyForest":true},"level":348,"class":"White Mage","money":10110,"is_in_party":true}

JSON length: 149

This discussion is preserved as it was. New answers, comments, and votes are closed.