I'm trying to make it so the player's inventory saves (Not the player's backpack and starterpack, just a GUI inventory). The ROBLOX Wiki lacks examples, and can't find any understandable answers
How would you save a table in DataStore?
1 answer
SetAsync / UpdateAsync
You can save a table to data store the same way you can save any other valid data type to data store; by passing it as the second argument to SetAsync or as the return value of UpdateAsync. The only exception is the table must be in either array or dictionary format, not a mixture of both. Saving a mixture of both will most likely yield losing the array part. Example:
-- Saving an array
DataStore:UpdateAsync("Test", {1,2,3})
-- Saving a dictionary
DataStore:SetAsync("Test", {a=1, b=2, c=3})
Data Limit
It's also important you know that tables are saved to JSON, and therefore the string length of the encoded JSON table is limited to how much memory can be stored at once (this is approximately 2^18 string characters). Going over this limit will cancel your save request.
Hope this helped, if you have any questions, just let me know.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Oh, so datastore only saves values, not instances?
Correct. If you wanted to save an instance, it'd have to be serialized, saved and decoded upon loading it.
Ok thank you