What do you want to achieve? Keep it simple and clear!
So im making a game with my friend, and im trying to make a top 1 leaderboard similar to a game (i forgot the name of the game) which is displaying player with highest stat and updates (of course)
What is the issue? Include screenshots / videos if possible!
i cant im too stupid to figure out
What solutions have you tried so far?
free model global leaderboard
please make a basic code because im tired its been 2 days
EDIT: i know that full code is againsts the rules but please
To make a leaderboard system like this, you need to use Ordered Datastores. If you want me to provide you with a script, I can try making one. Would you like to only display the highest rank, or all the top ranks?
local ds = game:GetService("DataStoreService")
local ordered_data_store = ds:GetOrderedDataStore("YOUR_DATASTORE_HERE") -- Replace it with your datastore
function GetHighestRank()
local Pages = ordered_data_store:GetSortedAsync(false,1) -- This sorts the datastore to pages which only have 1 key.
while true do
wait(0.01)
local Keys = Pages:GetCurrentPage() -- This grabs the keys of the current page.
for i, v in pairs(Keys) do -- This will loop through all the keys of the page (in this case, it's only 1)
return {v.key,v.value}
end
end
end
When you call the GetHighestRank function, it returns a table which contains the key name and value. My explanations in the script arenβt very clear, so if you want me to give you more details, I can.
okay but i have a problem
i tried to run this code and it didnt work (i edited it) i hope im doing everything right
for i,v in pairs(game:GetService("DataStoreService"):GetOrderedDataStore("I removed the datastore"):GetSortedAsync(false,1):GetCurrentPage()) do
print({v.key,v.value})
end
huh?
my brain isnt working properly i forgot what variable is βββββββββββββββββββββββββββββββββ
Wait, does your datastore contain keys in it? If it doesnβt, it will not print anything since there is no highest rank.
I tested your script and it works fine. Make sure you have saved atleast one key in the datastore before using this, or else it will not return anything.
Iβve been having a similar issue, but I know that the DataStore is not empty, and it still doesnβt print, would you be able to let me know what I could be doing wrong? (i tried to make a leaderboard)
Iβve never experienced this problem, so I am unable to provide you with an answer. You can try making a seprate devforum thread so that more people can see this issue.
I would like to make a separate thread, but I haven never done it before and recently just got permission to reply to messages. I have not the knowledge.