Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you get Player From UserId?

How would you get a player username from their Id, even if they aren't in the game?

something else that I forgot to mention is, regardless of if they are in the current game, how would you get someone's avatar. An example of a program doing this is Moon Animator, but I wanna know how they can do that with only the asset Id.

3 comments

0

GetHumanoidDescriptionFromUserId

0

game.Players:GetNameFromUserIdAsync(Id here)

0

Thanks :)

1 answer

You would use the Players:GetPlayerByUserId() which is exactly what your talking about the way you would use this is by getting the Player service and putting the GetPlayerByUserId() and just paste the id inside, it would look something like this

local Players = game:GetService("Player")
local PlayerId = 123456789

local player = Players:GetPlayerByUserId(PlayerId)

print(player.Name) -- Should print the player name

more on the GetPlayerByUserId here - https://developer.roblox.com/en-us/api-reference/function/Players/GetPlayerByUserId

1 comment

0

I saw this when searching for an answer, but I want to a function that will do this even if the player with the given id is not ingame.

This discussion is preserved as it was. New answers, comments, and votes are closed.