How to make a leaderboard with table?

  1. What do you want to achieve?
    What I want to achieve is to be able to make a leaderboard but instead of intValue I want to make it with a table.
  2. What is the issue?
    I can’t figure out how to make it with a table.
  3. What solutions have you tried so far?
    So I tried searching it up but couldn’t find any solutions so here’s the script I used :
local DiamondLeaderboard = DataStoreService:GetOrderedDataStore("DiamondLeaderboard")

local function UpdateLeaderboard()
	local success, errorMessage = pcall(function()
		local data = DiamondLeaderboard:GetSortedAsync(false, 5)
		local diamondPage = data:GetCurrentPage()	
		for rank, data in ipairs(diamondPage) do
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local name = userName
			local diamonds = data.value
			local IsOnLeaderboard = false
			for i, v in pairs(game.Workspace.GlobalLeaderboard.LeaderboardUI.Holder2:GetChildren()) do
				if v.player.Text == name then
					IsOnLeaderboard = true
					break
				end
			end
			if diamonds and IsOnLeaderboard == false then
				local NewLbFrame = game.ReplicatedStorage:WaitForChild("rankDiamond"):Clone()
				NewLbFrame.player.Text = name
				NewLbFrame.NumberOfDiamonds.Text = diamonds
				NewLbFrame.Rank.Text = "#"..rank
				NewLbFrame.Position = UDim2.new(0, 0, NewLbFrame.Position.Y.Offset + (570 * #game.Workspace.GlobalLeaderboard.LeaderboardUI.Holder2:GetChildren()), 0)
				NewLbFrame.Parent = game.Workspace.GlobalLeaderboard.LeaderboardUI.Holder2
			end
		end
	end)
	if not success then
		print(errorMessage)
	end
end

while true do

	for _, player in pairs(game.Players:GetPlayers()) do
		DiamondLeaderboard:SetAsync(player.UserId, player.leaderstats.Level.Value)
	end

	for _, frame in pairs(game.Workspace.GlobalLeaderboard.LeaderboardUI.Holder2:GetChildren()) do
		frame:Destroy()
	end

	UpdateLeaderboard()
	print("Leaderboard has succesfuly been updated!")

	wait(60)
end


Any help would be appreciated thanks! :slight_smile: