How to find character of a player when the player isnt playing the game or is on another server

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want to make a global leaderstat of a game of the top donated player.

  1. What is the issue? Include screenshots / videos if possible!

i cant get the character of a player when the player is not at the server

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i tried looking for on the dev hub

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

here is the part of the code where the character function is and placing the player at the leaderboard

local function getItems()
	local data = DataStore:GetSortedAsync(false, maxItems, minValueDisplay, maxValueDisplay)
	local topPage = data:GetCurrentPage()

	for position, v in ipairs(topPage) do
		local userId = v.key
		local value = v.value
		local username = "[Not Available]"
		local color = COLORS.Default
		local winners = game.ReplicatedStorage:WaitForChild("Bindables"):WaitForChild("WinnerEvent")
		
		Contents.Items.Nothing.Visible = #topPage == 0 and true or false
		
		local success, err = pcall(function()
			username = Players:GetNameFromUserIdAsync(userId)
		end)
		
		print(username)
		
		if position == 1 then
			color = COLORS.Gold
			winners:Fire(workspace:WaitForChild(username), 1)
		elseif position == 2 then
			color = COLORS.Silver
			winners:Fire(workspace:WaitForChild(username), 2)
		elseif position == 3 then
			color = COLORS.Bronze
			winners:Fire(workspace:WaitForChild(username), 3)
		end

		local item = Template:Clone()
		item.Name = username
		item.LayoutOrder = position
		item.Values.Number.TextColor3 = color
		item.Values.Number.Text = position
		item.Values.Username.Text = username
		item.Values.Value.Text = abbreviateValue and toHumanReadableNumber(value) or value
		item.Parent = Contents.Items
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Have you tried loading the players character through they’re user id?

2 Likes

i loaded their humanoid description but the charactor is not changing

how do i update the charactor