Global Leaderboard of Race Times

Hi guys,

I’m currently developing a simple racing game, with different maps, cars etc.
I’ve started saving and storing the record times for each players, so they just get a feel of getting better and better. Just providing a challenge to beat their time in the race. An idea popped up, of actually competing against all game servers, with a leaderboard diplaying “World Record Times”.

Currently, I’ve only been able to do this for a single server, comparing player’s race time against current record holder (server limited) and if it’s better than the current record time stored, then update that with the players time.

So, I’ve started looking into MessagingService, and attempted something like this:
local MessagingService = game:GetService(“MessagingService”)

local GlobalLeaderboard = game.ServerStorage.WorldRecordTimes.Terrain

GlobalLeaderboard.Changed:Connect(function()

local RecordTime = GlobalLeaderboard.Value -- record time in seconds.milliseconds

local RecordHolderId = GlobalLeaderboard.Holder.Value -- the current record holder UserId

MessagingService:PublishAsync("UpdateGlobalLeaderboard",{RecordHolderId,RecordTime,JobId=game.JobId})

end)

MessagingService:SubscribeAsync("UpdateGlobalLeaderboard",function(data)

if data.JobId == game.JobId then

return

end

print(data.RecordHolderId.."is currently holding record at: "..data.RecordTime)

end)

And I’m not quite sure where to actually go from here? Would I DataStore the Record Times of all servers, and then compare all the Record Times and eventually display the best one using MessagingService?

Could someone guide me a little bit, so I’m closer to the desired goal?

All help is appreciated,
excA

1 Like

MessagingService isn’t necessary to make a global leaderboard, it should be doable with just an OrderedDataStore. There is a good bit of discussion on the forums already about how to do this so I would recommend searching around. For example I found this tutorial on how to make a global leaderboard: How to make a simple global leaderboard

1 Like

This is what I use for my lead board but people on the topic for messagingservice told me datastore doesn’t update globally when I originally thought it did :joy: . So which is it lmao

I have recently found that post by googling around, and thank you. However I’ve been trying to make use of a Value saved within ServerStorage for use with OrderedDataStore.
That bit of code converted to make use of my values looks as so: https://hastebin.com/nejexalevi

And I’m still having troubles with it not outputing anything on the board or in output to be able to debug it. What am I doing wrong?

Hey, have you tried printing ps? If it is greater than 100 or less than 15, it will not display. I can guarantee the demo from my tutorial works.