How to make a simple global leaderboard

You could store it like this, and reset when the two value’s don’t equal each other.

Here’s a little pseudo code

local dateTable = os.date("*t", os.time())
local key = "Y:"..dateTable["year"].." M:"..dateTable["month"].." D:"..dateTable["day"]
local getData = --Get player's data
if getData["DayStored"]~=key then
    --New day, reset data and set new key
    getData["DayStored"] = key
    getData["ActualData"] = 0 --Add to this when they gain cash
end
6 Likes

That’s easier than I thought haha, thank you very much!

5 Likes

Glad you found it useful. The same principle would apply for other values, just remember to reset when the day is not the same, and create a separate value to save to other than your long-term storage.

6 Likes

How do I change it to display Money?

5 Likes

Hello! I want to know how do i set a line where i can set what players cannot appear in the leaderboard, some kind of banned people or developers who wants to test stuff with a high value of “Rebirths” without appearing on the leaderboard.

3 Likes

I discuss in detail how to do this in the FAQ section. Please read this before asking a question.

3 Likes

The easiest way to do this is check if a players name is on the list, and if it is, send the value 0 to the function.

In the reply above, I linked to the FAQ section which explains how to modify the value in detail.

Another solution is to change the max value to exclude those values.

6 Likes

Is there a way to return multiple values from the table so I can get say players rank.Value and Kills.Value?

4 Likes

Yes, but you have to make multiple copies of the script, and change where the data is stored (:GetOrderedDataStore(name)).

OrderedDataStores can only store a single numerical value, so that’s the best possible solution using Roblox, without owning your own data manager.

7 Likes

Okay I might just update the server every time the players kills.value or rank.value stat changes instead

2 Likes

Word of warning: You should limit your updates to at least once every 60 seconds, as there are data store request limits.

To clarify: This is only for data store values, value object are not subject to the limit.

Limits in detail (You have to scroll down): Documentation - Roblox Creator Hub

7 Likes

The global leaderboard isn’t working for me. It’s giving me this error in the output:


I’m not sure what that means…

2 Likes

AwardPoints was discontinued, so pull the value from somewhere else. (It might also just be internet connection) You can look at some of the above replies to figure out how.

6 Likes

Thank you, very helpful, my development team will be taking this into consideration!!

5 Likes

I know this is an older post; hope its okay to post here. I wanted to thank ThatTimothy for putting together such a thorough and educational post…and for sharing all of the resources. I actually pulled this model into my first game, and made the points modification suggested in the FAQ, and its worked flawlessly since.

A rookie question: My first game was only saving a single value in the Datastore. In my current game I’m saving many values to a single Datastore using a table. I only need the leaderboard to display a single value (Experience). Should I use a second Datastore to record Experience only, or is there a way to pull just a single value from the table into the leaderboard?

Old working code – I added the yellow highlighted replacing the above line:
image

New datastore saving – I would like to show only Experience in the board.

Again – appreciate the education here…

5 Likes

OrderedDataStores can only store one numerical value, and will only be able to sort their individual OrderedDataStore. Since a regular DataStore and the OrderedDataStore are completely separate, you must make a OrderedDataStore for each leaderboard you wish to have.

8 Likes

Thanks for the response and again for sharing this.

4 Likes

Hey, so I am not the best scripter. I am going to use this as a base to my leaderboard. But, how do I change it to leaderstat values? Because I am still getting to know lua, and it is confusing for me.

3 Likes

As I listed in the tutorial and in the replies below (please read them before you ask a question), you can change the value used.

5 Likes

Thank you so much this helped a lot!!

5 Likes