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

Player help needed?

Asked by
crut24 50
9 years ago

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

2 answers

Log in to vote
0
Answered by 9 years ago

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 :)

0
Do FindFirstChild with an uppercase F instead of lowercase, because findFirstChild is deprecated. EzraNehemiah_TF2 3552 — 9y
0
@LordDragonZord it still works but FindFirstChild instead of findFirstChild is just more efficient it won't effect the script Prioxis 673 — 9y
Ad
Log in to vote
0
Answered by
Reselim 35
9 years ago

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)

Answer this question