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