OrderedDataStores uses and documentation?

I’ve developed using SQL and Roblox DataStores before, but still don’t fully understand OrderedDataStores and why they can only store integers (Rather than some variation of Linq)

Is it used as a median/“foreign key” to represent information in another table? I can’t seem to find good documentation. My purposes would be displaying leaderboards based on a variety of stats inside user data (Kills, Matches played, KDR, Elo, etc)

Do I need an ordered datastore for each of these sortings?

Short answer, yes, you do need an ordered datastore for each statistic, since a table can’t be stored in OrderedDataStores. It may sound like a hassle but it isn’t that bad- just save the stat with whatever as the key (prefer the uid of the player).

So, with multiple stats, you’d have to get the ODS like this…

local DataStoreService = game:GetService("DataStoreService")
local Kills_Data = DataStoreService:GetOrderedDataStore("Kills") 
local Kdr_Data = DataStoreService:GetOrderedDataStore("Kdr") 
local Matches_Data = DataStoreService:GetOrderedDataStore("Matches") 

Then from there it’s like a normal datastore, but with extra functions like GetSortedAsync. If you need anymore help, here’s an old wiki page of OrderedDataStores that has an helpful example http://52.0.101.191/index.php?title=API:Class/OrderedDataStore

2 Likes

If you want to store values other than intergers, you will have to use regular data stores. A ordered dataStore is used for sorting intergers.

A good example of this would be for leaderboards. Unfortunately, you would have to make them seperate ordered data stores.

I recently made a tutorial on How to make a global leaderboard, which goes over how to make leaderboards based off of stats. If you have any questions with the tutorial, feel free to ask them.

If you have any questions throughout, feel free to ask them.

I figured this was the case. I had initially wanted to do an offsite server that I could use SQL on but that quickly became non-cost effective. Thanks.

1 Like