I wasn’t sure how I wanted to word this topic, so I labeled it the way it is displayed above. So…
I’m working on a game that utilizes “wins”. The wins is a numerical value that will have a global leaderboard. When saving the data, I will of course be using an OrderedDataStore.
My question, however, is, should I use the data saved in the OrderedDataStore as the data that shows up on a player’s leaderstat, or should I use a different DataStore to fetch the wins value that is displayed in the player’s leaderstat?
If this isn’t worded clearly, please lmk so that I can give further details. Thank you for all of your assistance!
What I would do is program it to where when the player first joins the server, their leaderstat wins is set to the value of their PlayerId’s value in the datastore. Then, when they receive a win, a server script will update the datastore value and then set the player’s leaderstat wins to what it was before plus one.
Hope that made sense, let me know if you need clarification.
If you’re only saving wins and you need it to use for a leaderboard, use OrderedDataStore in all cases of needing to access saved wins. OrderedDataStores sport the same functionalities as GlobalDataStores so you can read and write data like a normal DataStore, they just have the added benefit of being able to query results in a sorted manner.
I believe the DataStoreService has exposed methods both for GlobalDataStores and OrderedDataStores objects. The ones that you probably calling normal datastores are GlobaDataStore objects.
Global and “normal” DataStores are the same thing. GlobalDataStore is the superclass of all DataStore interfaces, GetGlobalDataStore returns the default game DataStore and GetDataStore allows you to use a named (and scoped, if you please) DataStore. There’s no difference.
You can’t order DataStores yourself because you can’t query every entry and perform manual sorting on them. If you were using an external service, you could code in that behaviour yourself but otherwise if you want to make a leaderboard you should be using OrderedDataStores.