Using DataStore2 for multiple saves

I want to know if it is possible to have multiple DataStore keys per player using the DataStore2 module, and if not, if there is another module that can do this.

I am making a building game. Each player can have up to 10 islands saved. I have already made a system to convert a player’s island into a string, so that is not the problem. The problem is actually taking that string and saving it to a DataStore. I figured that DataStore2 would probably be the best way to do this, but I cannot figure out how to have multiple keys associated with 1 player. I can’t just use 1 key for all 10 islands, because it would probably exceed the DataStore limits.

Because each player can have 10 islands, I need to save 11 keys for each player (the last one is to save any other information about the player).

I have read through the DataStore2 API and I can’t find anything about having multiple keys.

If its not possible, are there any other good modules that would work for this? I have looked at ProfileService and that doesn’t seem like what I’m looking for either.

You can utilise multiple keys under the DataStore2.Combine(masterKey, key1, key2, key3) method!

The master key should always be one constant key and never change. Key1 could be ‘Island1’, ‘Island2’, etc.
This is a really great method of DataStore2 as you can combine multiple keys into one datastore. This is always a very recommended way to use DataStore2. It can also be used the exact same

DataStore2(Island2Key, player)
DataStore2(Island3Key, player)

1 Like

Thanks for the help!

I have watched a tutorial and I think I understand DataStore2 pretty well now. There is only one thing I’m still confused about. I don’t know if I can make it use multiple DataStore keys for 1 player. I don’t want to use DataStore2:Combine() because having all 10 islands saved into 1 key would probably exceed the DataStore limits.

DataStore2("MainPlayerData", player)

DataStore2("Island1", player)
DataStore2("Island2", player)
DataStore2("Island3", player)
...
DataStore2("Island10", player)

Would that use a different key for each island, or will it still only use 1 key? My understanding is that you have to use :Combine() to make them use 1 key, but I’m not sure.

It would not exceed the datastore limits, if you check the datastore limits on the wiki page, you can see the limits are very high! And as long as you compress it as well as you can, there should be 0 issues.

1 Like