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

Player help needed?

I need to know how to get the UserId of a player just by knowing his name.

2 answers

This question is very simple, thus the answer is also very simple.

local player = game.Players:FindFirstChild(name) -- This will find the player based on the name, so make sure "name" is the name you have.

local userId = player.userId -- The id of a user!

Hope this helped :)

2 comments

0

Do FindFirstChild with an uppercase F instead of lowercase, because findFirstChild is deprecated.

0

@LordDragonZord it still works but FindFirstChild instead of findFirstChild is just more efficient it won't effect the script

If you want to get a player's userId from their username, even when they're not in game, use:

local username = "Builderman" -- Username goes here.

local userid = game.Players:GetUserIdFromNameAsync(username)

print(userid)

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