Datastores and tables trouble

I have looked at several posts on here, and googled a bunch, and I can’t seem to understand how datastores work.

I am wanting to store a table (keyed) into a datastore. I read somewhere that you can not do this unless the table is json encoded as a string. Then the string can be written to a datastore key (im using player.UserId). The part I don’t understand is how Roblox states each key in a datastore can hold 2 megs of data, yet a lua string (if I convert table to json string) can only be 200,000 characters. So how is each datastore key able to hold 2 megs of data?

Also, when looking in the examples on Roblox (which state nothing about datastore valid types) I see the examples will have one datastore for nicknames, one for inventory, etc… I have been just using one single datastore for everything (custom house inventory, player inventory, player outfit saves, regular inventory, among others) Should I be using multiple datastores? If so, would reading from each of them all add to a global limit on datastore access or does each datastore have its own limit?

It would be nice if you could just pass in a keyed table (with some value being sub keyed tables) to a datastore, and it just save it, just work. Of course I know you cant have things like instances, or cframes, or stuff like that, I am just talking about tables with bool, numbers, strings, and keyed tables of those.

1 Like

Hey, actually, Roblox’s data stores can save tables (arrays and dictionaries) as long as they only include valid data types which can be serialized via JSON (numbers, strings, booleans). In the past, all datatypes that were not strings, but were valid, had to be serialized manually with HttpsService, now Roblox does this automatically when you use the data storing methods, even with tables.

Regarding the limits; each key in a data store can hold up to 4MB of data (4,000,000 characters), so yeah you should be using multiple data stores, just be careful to not overload the data store’s request limits.

1 Like

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