DataStore2 Confusion

[1] What do you want to achieve?
I want to try and implement DataStore2 into my data saving.

  1. What is the issue?
    I have some confusions about it. So I have been searching through devforum reviewing code examples and I was mind-boggled. Here are my questions:
  • Is DataStore2 supposed to be used like the normal roblox DataStore? Saving and loading every once in a while, and when player leaves/joins the game?

  • Do I update DataStore2 everytime I want to change a value? Instead of updating the objectValue itself? (example, a Cash IntValue)

  • Do I have to manually setup game:BindToClose to ensure every player gets they data saved? Or does DataStore2 does it for me?

  • Am I supposed to create a new store everytime I have another type of data? If thats the case it might get tedious for my game seeing as it has like, what, 15+ types of data, including data that checks if a player might have unlocked a specific item, move, exp, strength, defense, stamina, points. The thought of making a unique store for each type of data makes me question if that will affect the performance/efficiency of the DataStore2?

  1. What solutions have you tried so far?
    I did search the DevForum for answers but so far I haven’t found any clear answers to my questions.
  • Datastore2 is just a module that uses DataStoreService but with 0 data loss.

  • Yes you have to use :Set to save the data, it will only save that data when the player leaves (It will use SetAsync once)

  • No

  • You can save tables with Datastore2 (It uses HttpService automaticly itself to encrypt the table)

Thanks for answering
But regarding the :Set() part, Im still confused.

So everytime I want to update data, (like add 30 coins to a player’s Coins) I have to use :Set()? Then can I just make a value and everytime it changes its value I bind :Set to it?

Yes, don’t use it when the player leaves. It caused a disaster for me. Use it whenever a value (that you want to save) changes. So if you have a “money” store, and you use an IntValue to manage the player’s money, everytime that IntValue changes (.Changed event) use :Set() on the money store.