How to get rank from a global leaderboard

Hey there,
I am thinking of making a global leaderboard for a game I’m making and I was wondering how I could get what rank players are on the leaderboard like if they are 1st or 2nd or 25th. If you have any idea on how thing would be achievable please let me know. Thanks

First let’s get to the questions. Does your game have a data store of what you want to rank?

2 Likes

Yes, I am trying to make a competitive leaderboard where the top 10 and top 25 players will get prizes at the end of the season. So its not really a leaderstat but its still a value being saved.

You’ll need to use GetOrderedDataStore() instead of GetDataStore() to achieve this.

2 Likes

Oh okay, What’s the difference between the 2?

Not much, just one orders the data according to the value of the key and value pair & in the other the data is unordered.

Because of this OrderedDataStores have access to an additional function:

Which is what is used to get a sorted dictionary of data from the OrderedDataStore itself.

2 Likes

Also would you happen to know how I can check if a value is or is between 2 numbers?

Oh thank you so much ill check it out

local x = 0
if x <= 3 and x >= -3 then
	--do code
end
2 Likes

Oh Alright thank you so much! :slight_smile:

Sorry for the late responce. But I just finsished eating lunch. Another question is what is the currency called and whats it parented to and the parent’s name.

2 Likes

The currency is just called “CompWins” and its parented to “PlrValues”

2 Likes

Ok give me a couple minutes to write a leaderbaord script.

2 Likes

Oh thank you so much! Take your time

Hey there. Not sure if you’re still on but I finished the board. Heres how it looks.


Heres the place file it’s too hard to explain. Feel free to use the scripts in your game. If you have any questions then feel free to ask.
Leaderboard test.rbxl (44.5 KB)

2 Likes

thank you so much, ill go try it out rn! :slight_smile:

2 Likes

ok but publish the place and turn on access to api services.

2 Likes

Hey nothing is showing up on the board when I use it but it does print my name

Are you putting this in your game or is it still in the place file?

2 Likes

Also did you delete anything. From replicated storage?