Is there a way to get a player's display name from their username or user id?

Hi,
I want to know if there is a way to get a player’s display name from their username or user id.

local Players = game:GetService("Players")

local success, result = pcall(function()
	return Players:GetUserInfosByUserIdsAsync({ 8000 })
end)

if success then
	for _, userInfo in ipairs(result) do
		print("Id:", userInfo.Id)
		print("Username:", userInfo.Username)
		print("DisplayName:", userInfo.DisplayName)
	end
end
4 Likes

It didn’t work at first when i checked the API it said you had to get the UserService, and not the Players service. But thanks it works.

1 Like