How to use DataStore2 - Data Store caching and data loss prevention

Don’t use more than one master key with Combine and you won’t have this problem. What you are describing is undefined behavior.

The documentation shows how to get the most up to date version of the module. I think I just need to remove that comment.

So you are saying that irrespective of the store, be it kills or something entirely unrelated like points, the master key shall save every single piece of data which I want to save under one huge data table?

Correct, that is the point of combining the data stores.

do you know of anyway I can use this with ordered data stores to make a game leaderboard?

How can i transfer data from main place to sub place or it is automatically done

im concerned about this topic being true

I think it is automatically done. My game has 2 places and all I did was just setting up a leaderstats, loading and saving the data.

Hi all, I was able to extend DS2 a bit by adding data modification of offline players. I modified __call to accept UserIds, which allows caching with the Id instead of player instance. When players leave, their data is saved using the UserId as cache key. There were minimal modifications to the module (primarily messing with DataStore2.__call). I tested this with admin commands like setting a player’s gold while they are offline, shutting down the server, and checking if the player has that much gold in a new server. I still accept Player instance as an argument, it’s only used to access Player.UserId now so I don’t have to modify every instance of the call.

2 Likes

Remember that the license requires that you open source any changes you make to the module.

I have found a problem with how Im saving data if the server shuts down, getting a lot of throttles in some cases. I will try to fix this and make a pull request

Do I still have to “combine” any key I use, or has this been updated to be automatic?

As the documentation says, you still need to combine keys.

2 Likes

@Kampfkarren

Does calling Store:GetTable() respect the amount of times to retry using Store:SetBackup?

How would I get data from a specific player in the command bar?

1 Like

I didnt really understand the :OnUpdate() thing.

if you modify modify your datastore it will return a function with the value after the modification (modifications: Set (), Increment ())

How should I do :Combine()?

Is it like :GetDataStore(something)?

Example:

local DataStore2 = (Your_Module)

DataStore2.Combine("GameData_V1","Power") --MasterKey,Save_Key

local PowerSave = DataStore2("Power",player)

print(PowerSave:Get(0))

use Combine with all your keys to avoid problems

It should, yes.

There’s not currently an easy way to do this without doing something like Does CrazyMan's DataStore Editor work for DataStore2? - #6 by MFCmaster1234.

1 Like

Why is this happening, I marked where I was saving the table to the data store, is that expected to happen with tables like this? How could prevent this error from happening