How to make global player ranking system?

Hello everyone. I have seen interesting ranking system in game called “Obby Royale”. In this game you can always see on what place you are, even if you are 783,234th. And i am wondering how they made this system, if everyone on Dev Forum and in other social media saying that it is impossible.
Thanks for help!

2 Likes

Maybe they use a MemoryStore to keep data and track it among servers. MemoryStores are also used for server lists (i think).

Also it isn’t impossible if they did it

1 Like

I’m not at my computer at the moment, and I couldn’t tell you a specific way to implement this, as you could use many solutions.

I imagine Obby Royale store and retrieve the data they use in their own external database (whether that be within a Microsoft SQL, PostgreSQL, NoSQL etc) and interact with this DB with their own API endpoint, which probably queries data within a table they’ve made for this.

From there you can call the API using HttpService on the Roblox side.

You’d need to protect your DB and API endpoint(s) with sufficient credentials or API keys so only apps which have the credentials can call your API.

Not sure if a system like this would be against Roblox TOS? I imagine if you get a GDPR deletion request, you’d also need to maintain this data storage solution too and delete the user’s data from it.

1 Like

yeah thats true, for a massive scale like so.

i think a memorystore would work on a smaller level, but not sure.

I’ve never heard of memory stores before, I’ll have a look into them.

I was just thinking if the user wanted other functionality like ordering of data etc. :slightly_smiling_face:

1 Like

Im pretty sure you can return sorted maps from MemoryStores. MemoryStores are used for cross-server data, I need to learn how to use them myself. I just understand the basics of it.

2 Likes

ordered data stores can be used for this

Ordered DataStore (Global Leaderboards) - Roblox Advanced Scripting #18 (2024)

1 Like

Just reading the docs: Memory stores | Documentation - Roblox Creator Hub

Noting this bit: “in-memory data storage accessible from all servers in a live session”.

Would this not mean that this data doesn’t actually save and persist?

Like if the game had no servers up and running, would this memory still be accessible?

I think it can still work with this, you’d just need to initialise it with the UserId as the key, and the ‘Value’ you’re attempting to create a ‘rank’ for as the value to store in this MemoryStore the moment the user joins the game.

Even if this is the case, this is heavily dependent on the records in the MemoryStore, when there’s a lot of filled servers, your rank might be lower, but if you were the only one playing the next day, suddenly you’re first…

1 Like

Thing with this is, you can only fetch pages with this (limit is 100 per request I believe).

You’d be on forever constantly fetching the next page in order to get to, in the OP’s example, 700,000+.

1 Like

yeah, if they want it live rank updating memory stores, but im not very sure how you would do this w/o extra databases in place.

I took the question as “live” rank showcases.

1 Like

that is right

but also, 700k would consume a lot of memory i have never used memory store before so idk if its lower than the limit
that is 700k bytes it will be more if we calculated the table keys and values

1 Like

i just checked. the formula is

64kb + 1kb * (num of players)

2 Likes

how do I can merge memory store and profile service(open source module script)?

for example i have points and game calculates on what place you are?

Again, MemoryStores remove data after a certain TTL, so you’d need to re-insert the data after a certain TTL, depending on if that user is still online in the game if you’re using ProfileService (also, I recommend using the updated version, ProfileStore).

Additionally, even if you were to find a workaround like this, the memory limit of a MemoryStore is 64KB + 1KB * [number of users], which at absolute minimum, will be 65KB. It’s not a scalable solution if your game gains traction with many users playing. Backing up this point, if you look at the memory stores documentation, in the initial picture it even says is “Do you expect to have fewer than 1,000 keys?”, which suggests a sorted map shouldn’t be used for huge data sets (like 700,000 keys for example).

Unless anyone has any other ideas or if I’m missing something obvious, I would think the only way to implement a resilient, scalable implementation of this functionality is to create your own DB and API, link them together (personal preference is PostgreSQL with an Express API or something, there’s a bunch of frameworks and fancy magical options you can use) and call your API via Roblox, maybe every few minutes to get the up to date ranking for that player.

You could also use that same data source to make global leaderboards and all sorts.

That’s how I imagine many of the big games do this, even Obby Royale.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.