:GetCurrentPage Not Working

Hey. I am making a custom leaderboard, and I ran into a problem with listing the players. When I try to get the player via :GetPlayerByUserId, it doesn’t give me a player. It errors when I try to set the playerName text value to the plr.Name. I don’t understand why this is nil. Thanks.

local cashDss = dss:GetOrderedDataStore("Wins")
local template = script.Parent.Template
local container = script.Parent.Container

local function updateLb()
	for i, v in pairs(container:GetChildren()) do
		if v:IsA("Frame") then v:Destroy() end
	end
	local result = cashDss:GetSortedAsync(false, 5)
	local topFive = result:GetCurrentPage()
	
	for rank, data in ipairs(topFive) do
		local plrId = data.key
		print(plrId)
		local points = data.value
		local clone = template:Clone()
		clone.Place.Text = "#"..rank
		clone.PlayerName.Text = players:GetPlayerByUserId(plrId).Name -- error part
		clone.Value.Text = points
		clone.Icon.Image = players:GetUserThumbnailAsync(plrId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		clone.Visible = true
		clone.Parent = container
	end
end

while wait(5) do
	updateLb()
end

just do

local userName = game.Players:GetNameFromUserIdAsync(tonumber(savedData.key))

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