Its posible to get a players Name or the player UserId by the DisplayName (ingame)

I want to get the player Name by the DisplayName of the user that is ingame but im not quite sure how to do it

if you dont understand me its like the Player:GetPlayerFromCharacter function, but instead Player:GetPlayerFromDisplayName quite like that

Hi Mau,

Since a Player instance has a DisplayName property, you can iterate through all players until that property matches the name you are looking for.

Custom function example:

local Players = game:GetService("Players")

local function GetPlayerFromDisplayName(name)
	for _, player in ipairs(Players:GetPlayers()) do
		if player.DisplayName == name then
			return player
		end
	end
end
1 Like