Gui Leaderboard

I am trying to create a leaderboard for donations on a PlayerGui. How would I get the player for this?

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local TotalLeaderboard = DataStoreService:GetOrderedDataStore("DonoDataStore")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = TotalLeaderboard:GetSortedAsync(false, 10)
		local TotalPage = Data:GetCurrentPage()
		for Rank, data in ipairs (TotalPage) do 
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local Name = userName
			local Total = data.value
			local isOnLeaderboard = false
				for i, v in pairs(player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").LeaderboardRemove:GetChildren()) do
				if v.Player.Text  == Name then 
					isOnLeaderboard = true
					break
				end
			end
			
			local userId = player.UserId
			local thumbType = Enum.ThumbnailType.HeadShot
			local thumbSize = Enum.ThumbnailSize.Size420x420
			local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
			
			if Total and isOnLeaderboard == false then
					local newLbFrame = game.ReplicatedStorage:WaitForChild("Leaderboard"):Clone()
					newLbFrame.PlayerImage.Image = content
					newLbFrame.Player.Text = Name
					newLbFrame.Total.Text = Total
					newLbFrame.Position = UDim2.new(0.206, 0, newLbFrame.Position.Y.Scale + (0.006 * #(player.PlayerGui.WaitForChild("ScreenGui").LeaderboardRemove:GetChildren())), 0)
					newLbFrame.Parent = player.PlayerGui:WaitForChild("ScreenGui").LeaderboardRemove
				end
			end
	end)

	if not success then
		print(errorMessage)
	end

end

while true do 
	
	for _, player in pairs(game.Players:GetPlayers()) do
		TotalLeaderboard:SetAsync(player.UserId, player:WaitForChild("Dono").Value)
	end

		for _, frame in pairs(player.PlayerGui:WaitForChild("ScreenGui").LeaderboardRemove:GetChildren()) do
		frame:Destroy()
	end

	updateLeaderboard()
	print("Total Updated!")
	wait(5)
	end

Do you wan’t a script for it? If so than i have one, it’s not so modern though

Sure! I’ll look into it and see if I can utilize it!

One more thing, you said PlayerGui, so do you want the leader-board on a part or do you want it as a ScreenGUI?

I would like it as a ScreenGui, I already know how to make leaderboards onto parts.