I need to know how to get the UserId of a player just by knowing his name.
This question is very simple, thus the answer is also very simple.
1 | local player = game.Players:FindFirstChild(name) -- This will find the player based on the name, so make sure "name" is the name you have. |
2 |
3 | local userId = player.userId -- The id of a user! |
Hope this helped :)
If you want to get a player's userId from their username, even when they're not in game, use:
1 | local username = "Builderman" -- Username goes here. |
2 |
3 | local userid = game.Players:GetUserIdFromNameAsync(username) |
4 |
5 | print (userid) |