Ordered Datastores: finding a page of specific key

Hi,

I’m currently creating my own leaderboard system. I’ve managed to setup all of it fine, except for one feature: a bar on the bottom which tells the user their position in the ordered datastore and their score:

I was just wondering, what’s the best way to go about doing this? I was thinking about loading up all the ordered pages using :GetSortedAsync() then checking against each page until the player’s ID matches the page’s key, but this method seems quite heavy, especially if the game had lots of players.

Is there any function like :GetPageWithKey(userid) out there which would make this easy?

Any suggestions?

Thanks

3 Likes

I don’t think the function you want is a thing, but if it is, it’ll be on this page.

Maybe just estimate the current level based on exponential distribution? it’ll give the player an idea of where they stand, but it doesn’t need to be exact, necessarily.

2 Likes

That’s a good idea - I was just hoping there’d be a more simpler method

Unfortunately there is no API for any sort of custom querying from DataStores, which makes me sad :frowning:

In Angels Fifteen, I had to linearly search until I found the player. With a lot of players and a lot of data, this seemed to take anywhere from 2-15 seconds, which basically makes it feel broken to the end user.

6 Likes

Hmm that’s a shame. I think I’ll skip this feature for the time being then, since it seems too ineffective to implement. Hopefully Roblox cover this in their new leaderboard system. Thanks for the advice.