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

Is there a way to automatically get someones roblox user id?

Asked by
16OO1s -4
4 years ago

For example I'm making a starter menu and would like to have a page where it says "profile" and would like to automatically have your roblox USER ID shown and your "Account" age but I'm not totally sure how to do it.. like I've tried everything and nothing is working

3 answers

Log in to vote
0
Answered by 4 years ago

You can get a players properties(such as their account age and userid by doing something like this)

local plr = game.Players.LocalPlayer
local UserID = plr.UserId ------ Then you can change that to anything like AccountAge, MembershipType and Every property in player

0
Do I put this in a text label? 16OO1s -4 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited by Leamir 4 years ago

Check the player properties, what you're looking is there.

local Player = game.Players.LocalPlayer

local AccAge = Player.AccountAge
local UserId = Player.UserId

https://developer.roblox.com/en-us/api-reference/class/Player

0
Wdym? Sorry I'm very new to scripting and likeee yea 16OO1s -4 — 4y
Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
4 years ago

The easiest way to do this is by using GetUserIdFromNameAsync

Here: https://developer.roblox.com/en-us/api-reference/function/Players/GetUserIdFromNameAsync

Example code:

game.Players.PlayerAdded:Connect(function(p) -- PlayerAdded event
local UserId = game.Players:GetUserIdFromNameAsync(p.Name) -- How to use it; must be a string and a valid username.
print(UserId) -- Prints their userid
end) -- Ends this event
0
I'm so confused tbh I wish it was much simpler 16OO1s -4 — 4y
0
It's actually really simple though. One line: "game.Players:GetUserIdFromNameAsync("Pupppy44")", and it returns 131470756, my userid. Pupppy44 671 — 4y

Answer this question