I need help making a DataStore leaderboard

I’m making a donation leaderboard for my game, i alredy got my way to save the Robux from the donations at the DataStore, and after saving it, i wanted to put it on a leaderboard, that is almost completed, but im having some issues by getting the value on the “GetOrderedDataStore”, i tryed using the code that is a the Help page, just for test, and it still don’t get the stored value from real players.

local DataStore = game:GetService("DataStoreService")
local pointsStore = DataStore:GetOrderedDataStore("Donates")


local function printTopSixPlayers()
	local isAscending = false
	
	local pageSize = 6
	
	local pages = pointsStore:GetSortedAsync(isAscending, pageSize)
	
	local topTen = pages:GetCurrentPage()
	
	for rank, data in ipairs(topTen) do
		local name = data.key
		local points = data.value
		print(name .. " is ranked #" .. rank .. " with " .. points .. "points")
	end
end

pointsStore:SetAsync("Alex", 215)
pointsStore:SetAsync("Charley", 30)
pointsStore:SetAsync("Sydney", 20)

printTopSixPlayers()

#help-and-feedback:scripting-support would be more appropriate for this sort of question


I suspect that you’ve previously saved players’ data using a normal datastore. However, the ordered datastore is entirely seperate of the normal datastores, and you have to save the data seperately.

I would recommend just adding another line to your current saving system (not the one shown in the screenshot), that gets an ordered data store and saves a value with the same key and value as the normal datastore.

1 Like

nobody donated so far so i changed to it like you said and it worked, thanks!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.