Top Donor not working?

I am trying to make a “Top Donor” Text Label on my surface GUI. I used a tutorial off the devforum and changed it to fit my needs, but it doesn’t work and I don’t know why.

Script:

local DatastoreService = game:GetService('DataStoreService')
local Players = game:GetService('Players')

local DonatorsDatastore = DatastoreService:GetOrderedDataStore('Donators')

local refreshInterval = 5

local donatorsShown = 1

local function refresh()
	-- get the donators
	local pages: DataStorePages = DonatorsDatastore:GetSortedAsync(false, donatorsShown, 1, 2^63)
	
	print("Got pages")



	-- loop over the donators
	-- rank is a range from 1 to #donatorsShown
	-- data is a dictionary/table containing the userId and the amount donated
	for rank, data in pages:GetCurrentPage() do	
		local userId = data.key
		local amount = Players:GetPlayerByUserId(userId):WaitForChild("AmountDonated").Value

		-- get the name based on the userId
		local name = Players:GetNameFromUserIdAsync(userId)

		-- get the headshot profile image of the donator
		local profile = Players:GetUserThumbnailAsync(userId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size48x48)

		-- clone the donator frame

		script.Parent.SurfaceGui.DonorName.Text = name
		script.Parent.SurfaceGui.DonorImage.Image = profile
	end
	print("looped")
end

while true do
	refresh()
	print("refreshed")
	task.wait(refreshInterval)
end

You should define “what is not working”. We can’t just guess what your problem is.

Is it not displaying? Is it showing an error? etc…

Sorry about that, basically yeah, the text and image aren’t changing. All of the prints are working fine, but nothing is changing. No errors are being displayed either.

Are you sure there are data already in the OrderedDataStore?

1 Like

This was the issue. Thanks for the help, the leaderboard is working flawlessly now!

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