Help with leaderboard datastores. (Time Trial)

I’m working on a Time Trial obby, where players can complete different obby stages, and have their personal bests recorded. I also want to have a leaderboard for each stage (top 25 records). But I’m not 100% sure what the best way to get/store the data for those leaderboards would be.
I’ve been using OrderedDataStores (one store for each stage), and everything works fine. But it uses one datastore per stage. I plan on the game to have at 25-100 stages. I assume 100 datastores for the stages probably won’t work. The docs on datastores say to create fewer datastores, but it doesn’t explicitly say if there’s a limit on how many you can create.

I’m a pretty experienced scripter, but datastores are definitely not my forte. Would using OrderedDatastores (aka what I currently have) work fine? If not, what would be a good alternate solution? From what I can get from documentation, using a normal datastore with ListKeysAsync() seems like it could potentially work, but I’m not exactly eager to implement a totally new system if the one I already have doesn’t need to be changed (ListKeysAsync() also has the PageSize param, so honestly I don’t see a reason why this wouldn’t work - Edit: except that it really only returns the keys and not the actual values from what I can see…).

Would it just be better to have a datastore where players can get their personal bests from. And another datastore to store the top 25 times?

Overall, my current system works fine, but I’m not sure it’s optimized or easily expandable (mainly the 100+ ordered datastores part…), and I’d really like some outside opinions. Any thoughts? (thanks in advance :D)

(This is my first forum post in…ever? If I need to change anything about this post, or if something is unclear, let me know and I’ll try and get to it right away.)

Hi! I suppose you can reduce the number of datastores by adding a value for the level, this feels more efficient to me as the way I look at it, if we have a lot of datastores, means a lot more exhaustion of the DataStoreService, which could lead to more frequent errors (?), one way I think you can approach this is as follows:

  1. continue ordering the datastore on the time value, but now create filters based on the corresponding level
    a. the algorithm should do as follows, if the level is the level needed, it stores it into a table, then you check the number of entries in the table, once you reach the amount you need : break
    b. this can be memory intensive, but I believe this is better approach than having that many more times of datastores
  2. have the script that updates the leaderboard look for the specific level

I hope this helps!

Okay I think I can wrap my head around that, I’ll try something like that! Thanks for the help :D.