How can you get the person with the most data in a ordered data store?

Hey i have not seen posts about this and i need some help. So im making a thing in my game it uses ordered data stores but i dont know how to get the person with the most data. Can anyone help me?

could you provide your data store script

local donateAmounts = {5, 50, 100, 1000, 5000, 10000, 100000}local ids = {1279 - Pastebin.com um ok this is the link to the script (its a donation board)

try this im not sure if its gonna work tho

local dss = game:GetService("DataStoreService")
local Donatorsdss = dss:GetOrderedDataStore("Donators")
local Donators = buildingsStore:ListKeysAsync("cash")
local highestdonatornumbers = {}
for i,v in ipairs(Donators) do
table.insert(highestdonatornumbers,v)
table.sort(highestdonatornumbers,function(a,b)
     return b < a
end)
end
local HighestDonatorsnames = {}
for i,v in ipairs(Donators) do
for z,x in ipairs(highestdonatornumbers)
if v == x then
table.insert(HighestDonatorsnames,i)
end
end
end

Use OrderedDataStore:GetSortedAsync.

Ok i made this local dss = game:GetService("DataStoreService")local ods = dss:GetOrderedDataS - Pastebin.com but for some reason it doesnt print the name and the id

I literally made it its easy

local pages = ods:GetSortedAsync(false, 100)
local top = pages:GetCurrentPage()

for rank, data in pairs(top) do
				if rank == 1 then
					username = Players:GetNameFromUserIdAsync(tonumber(data.key))
					id = Players:GetUserIdFromNameAsync(username)
				end 
			end	

Yes it was that easy lol

1 Like