How to get player's account age?

	local userId = UserSearch.Text

	if tonumber(userId) then
		local plrInfo = game:GetService("UserService"):GetUserInfosByUserIdsAsync({tonumber(userId)})[1]
		if plrInfo then
			local age = plrInfo.AccountAge
			UserAge.Text = age

Output: Unable to assign property Text. String expected, got nil.

1 Like

The error is occuring because AccountAge isn’t contained within the plrInfo table:

While you can use .AccountAge on a player Instance, that is only possible if the user is in the server.
In order to access the account age of a player not in the server, you will need to use a proxy hooked up to one of the various Roblox APIs, such as ones listed in Swagger UI. I don’t believe it tells you the actual age, but it does tell you when the account was created, so you can calculate it from that


In this case, how do I retrieve account age of a player when a player is in the server?


No, as in when you enter a player username through textbox, it comes out as the player’s account age.

From their UserId…?

Or you mean when they aren’t in the server or…?

When there are in the server. (thanks alot)

Is there a way to retrieve player’s account age when you enter their username through textbox, it can be from their userid or by their username. (when there are in server, else it will show nil)

If you have their user ID:


If you have their user name:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.