i mean, like, :GetCharacterFromPlayer and vica versa is there a :GetNameFromDIsplayName or something similar?
COMMUNITY QUESTION
is there a way to get username from displayname?
1 answer
local Part = script.Parent --Part in the workspace
Part.Touched:Connect(function(It) --The variable "It" will be the bodypart, the parent of the bodypart is the character.
local Humanoid = It.Parent:FindFirstChild("Humanoid") --Find the humanoid in the Character
if (Humanoid ~= nil) then --Checking if the humanoid exists or not. If it does, then do this
local DisplayName = Humanoid.DisplayName --Get the displayname of the humanoid
if string.find(DisplayName, game.Players:FindFirstChildWhichIsA("Player").DisplayName) then --If we find a player with a displayname just like the humanoids display name, then
local PlayerTable = {game.Players:FindFirstChildWhichIsA("Player")} --Set a table for the player
local PlayerWithDisplayName = PlayerTable[1] --This is the Player with the display name, we got the player from the table.
print(PlayerWithDisplayName.Name) --Now, print the real name of the player with the displayname.
end
end
end)
I made a script for a part when you touch it, it gets the players name from the displayname.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
dont think there is. you probably wont need it anyways tho. if you have the display name, you will most likely have the player so you could just get the username from that.
yes i was just curious