What is the best way to save datastores?

Recently, I’ve been thinking of making a game that saves peoples progress, and I’ve never used a datastore before. Personally, I think the solution is to save an entire table in one key for each player, but I want to know if there is a better way of doing this. Do you have any suggestions, or what would you do?

Thank you for taking the time to read this.

Personally I would do what your saying and wrap all data into one table or even put tables inside of the main save table. This is completely up to you but tables are one of the more efficient ways of saving data using your own systems.

1 Like

Keep in mind the limitations datastores have.

When storing data try to keep characters to a bare minimum

Example

Let’s say your data stored looks like this

InventoryData = {
Items = {
["Amazing_Potion"] = {Rarity = "Rare",Amount = 10},
["Basic_Potion"] = {Rarity = "Common",Amount = 5},
},
Weapons = { 
["Great Sword"] = {Rarity = "Common",Durability = 100,Level = 5 , Experience = 25}
}
}

First, I would give each Item an ID and store it within a module so I can fetch the name of the item from its ID. When you make a module to store item information you don’t need to store useless data like Rarity.

Then I would reframe from spelling things out like Amount and if I have to shorten it as much as I can. And because Items won’t have any other values besides amount we can just set the Item to equal the amount.

After applying the changes/tips and tricks I have mentioned my datastore would look something like this

InventoryData = {
 I = { --// Items
  ["I2"] = 10,
  ["I1"]  = 5,
 },
 W = {  --// Weapons
  ["W1"] = {D= 100,L = 5 , E = 25}
 }
}

This is just how to fully utilize the space in your datastore

2 Likes

Use tables. They are the best and really only good way to save your data if your not using datastore2. :slight_smile:

You shouldn’t worry about staying within datastore character limits. The only times you should worry is when you do the extreme.
As an example for the game I work for, RetroStudio (Users are able to create their own games and code them with block coding, it is stored purely through DataStoreService), The average data count of a store is around 100k characters, far below the 4 million limit.