STOPEATCAK
(RemakingReality_Cake)
July 4, 2022, 5:59am
#1
I want to get a user’s DisplayName from a Username or UserId without the user having to go into the game. Is there a way to do this yet?
Code below, and yes, this is how its supposed to work until i get the display names working.
local player = game.Players:GetNameFromUserIdAsync(1829034891)
print(owner)
script.Parent.Text = player
This answers your question.
Get display name out of Username/UserId
Make sure there is nothing that solve your problem before posting, sometimes just a quick search is needed and you have your answer.
STOPEATCAK
(RemakingReality_Cake)
July 4, 2022, 6:17am
#3
wait im confused,
how do I use this? its not working for me
1 Like
Typo in previous post *
Here this works :
local UserService = game:GetService("UserService")
local success, result = pcall(function()
return UserService:GetUserInfosByUserIdsAsync({80000}) -- UserId in here
end)
if success then
for _, userInfo in ipairs(result) do
print(userInfo.DisplayName) -- User displayName
end
end
aseden
(aseden)
July 4, 2022, 7:34am
#6
Yeah its pretty easy actually, its just
game:GetService("UserService"):GetUserInfosByUserIdsAsync({UserId})[1].DisplayName
I don’t know why every guide makes it so complicated
1 Like
Forummer
(Forummer)
July 4, 2022, 2:33pm
#7
Worth wrapping it in a pcall()
as it’s a network call which can fail (leading to errors).
2 Likes