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

How do I figure out someone's ID with a script?

Asked by
Nosteal 50
9 years ago

I really don't know how to do this. All I know is that you gotta get the player... and that's it.

2 answers

Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
9 years ago

There's actually a Property in the Player that you can use to get it. Just use a script to get the player, then use this line of code:

PlayerID=Player.userId

If you don't know how to get the player, it can be done easily from a LocalScript using LocalPlayer, like this:

Player=game.Players.LocalPlayer
PlayerID=Player.userId

Also, from a server script, you could use a PlayerAdded function like this:

game.Players.PlayerAdded:connect(function(Player)
    PlayerID=Player.userId
end

There you go. I believe that should sum it up for you. If you have any further problems/questions, please leave a comment below. Hope I helped :P

-Dyler3

Ad
Log in to vote
2
Answered by
iSvenDerp 233 Moderation Voter
9 years ago

Hi. I'm on mobile if it's confusing.

game.Players.PlayerAdded:connect(function(player) --When a player joins they create this function called 'player'

      print("User ID: " ..player.userId) --We indicated the userId with '.userId' inside 'player'.

end)

Let me know if this helped:)

Answer this question