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

How can I get a player's ID?

Asked by
Mystdar 352 Moderation Voter
8 years ago

Either from when they join with

game.Players.PlayerAdded:connect(function(player)

or from their user name,

game.Players.LocalPlayer.Name

how can I get their ID?

1 answer

Log in to vote
1
Answered by
Spectrobz 140
8 years ago

The userId is a property that you can get from a player instance

game.Players.LocalPlayer.UserId

If you want to find the userId from a player which is not in the game, you might wanna use this function http://wiki.roblox.com/index.php?title=API:Class/Players/GetUserIdFromNameAsync

And of course, you can get a player's name from userId http://wiki.roblox.com/index.php?title=API:Class/Players/GetNameFromUserIdAsync

You should take a look at the Roblox API if you need specific functions, they might already exist.

Ad

Answer this question