a global leaderboard that tracks how fast a player completed a map…
I already have a timer with a working GUI thanks to @luya_yobanka in post below
was setting up a clone of the global leaderboard simple set up from this post
which was a lot of help getting the UI together but i’m stuck now because his and many others I’ve googled base their globals on coins, points, etc but I’d like to track a time.
would anyone know the proper way to set this up please?
I followed the simple global and they also set up a ordereddatastore, I pretty much have first bit of script down I just don’t understand how to get player times
If you have a system for tracking how fast someone completed a course. Then all you would have to use is :SetAsync() into your OrderedDataStore. So how it would work is once the player completes the race, you’d insert their time into the DataStore. Example:
local Store = game:GetService("DataStoreService"):GetOrderedDataStore("StoreName")
local function raceFinished(player, time)
local key = player.UserId
local success, err = pcall(function()
Store:SetAsync(key, time)
end)
if not success then warn(err) else
return print("Saved time for, ".. player.Name)
end
end
Then in your leaderboard script you could run another pcall function using :GetNameFromUserIdAsync() to get the player’s name since the key is their userId which never changes (to my knowledge). Then compare using your Order Data Stores, :GetSortedAsync() function and do your leaderboard stuff.
I don’t have a system for getting the players info saved. I just don’t get what leaderboard scripting is like though… is there a tutorial I can follow for it? cause I’ve looked and most all globals are not based on time. would I just need to change from say ‘cash’ to ‘time’
As long as you have the value stored somewhere, you can put it on a leaderboard. That’s how coins, points, and other currency can be stored. Time is just a number.
For my specific leaderboard, you can either modify where the value is pulled from and saved:
or, you can save to the same ordered data store and the leaderboard will use the saved data. (If you do this make sure to remove the saving part)
To store data, it has to be on the server. The client can’t store it’s own data. You could use RemoteEvents to send this value to the server, but this has security risks. Ideally, you should have the data being tracked on the server for security purposes. If the client needs it, you can either use value objects or RemoteEvents to send it to them.
There is no way to send information to the server from a client without using RemoteEvents or RemoteFunctions. RemoteEvents and RemoteFunctions exist solely for client-server and server-client communication.
Any other way that works is most likely not intended behavior and not a great idea to use. Is there a reason you wish not to use remote events?
Hello @CrillicD, just wondering if you have managed to get your script working, as me and my son are needing a similar script. We have a working timer in leaderstats and would like to know how to register the time on a global leaderboard when a certain block is touched. We have set up an ordered data store but it is not registering the time. Thank you.