How to script a Global Leaderboard

I’ve tried to make a Global Leaderboard without success now. I’ve understood that I need a DataStore (which I have) and I have to use OrderedDataStore. I actually got it to work during one attempt but it didn’t work in my actual game for some weird reason, so I’m back to where I started.
What I’m trying to do:
I’m trying to make a Global Leaderboard get the top ten (the people with highest numbers) stored on a DataStore named “TokenDataStore”.

So it’ll be something like tokens = value Username = game.Players:GetNameFromUserIdAsync(key), not sure on how to define what place you are on.

I’m new to scripting so providing examples or a detailed description on what to do is appreciated. If you’re wondering what I meant with Global Leadersboard it’s this:
image
(this leaderboard is not by me)

Thanks in advance!

1 Like

If you want a example on how to make them, there is a demo in my tutorial on How to make a simple global leaderboard. Try looking at that, if you have any more questions feel free to ask.

4 Likes

Didn’t see the tutorial earlier. I’ll post another reply once I’ve read it and either understood it or have some questions. Thank you!

Can you say what wasn’t working?

I don’t know. I got no errors or anything, the script just simply didn’t work in my actual game, I checked settings and all other scripts.

So… Uh… Can you put the script?
To maybe know what is wrong…

Checked out your tutorial but it’s based on the PointsService (no longer working) making it break so I were unable to learn anything from the demo.

Here’s the whole model with scripts and all. Keep in mind only one of the sides as a script enabled (disabled the other three)
leaderboard.rbxm (15.3 KB)

:sweat_smile: I didn’t expected that but It will be easier

When you want to get the error message but also want the Script to resume

local success, errorMessage = pcall(ChangeDataStoreUsed)
if not success then
	warn(errorMessage)
end

That’s exactly what’s at line 278 to 281? But to my surprise it does neither of them in my actual game…

1 Like

I think I will need the entire game or Scripts that would communicate with (if there is) :frowning:

That’s sadly not possible, but I’ve tested by disabling all other scripts with no effect.

1 Like

So it doesn’t require others Scripts?

Not at all. It requires a database but it’s already created and saved. I also use the same scripts in my test place and my actual game.

1 Like

In the line 125 of the “Leaderboard Billboard Script” there is :

Leaderboard[item] = {value["key"], value["value"]}

I wonder if it should be that instead :

Leaderboard[item] = {key["key"], value["value"]}

That just causes an error.

It doesn’t make errors for me but I can’t really test it since I use the Baseplate world :smile:

That was with the exact model in a regular baseplate though. I beleive it would be easier to just rescript the whole leaderboard, would you help me with that?

Yes and I thought same before you said that! :joy: LOL