Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you get Player From UserId?

Asked by 3 years ago
Edited 3 years ago

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.

0
GetHumanoidDescriptionFromUserId Ziffixture 6913 — 3y
0
game.Players:GetNameFromUserIdAsync(Id here) Brycefitz2008 2 — 3y
0
Thanks :) Dr_Smartypants123 86 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

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. Dr_Smartypants123 86 — 3y
Ad

Answer this question