Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I get the Account Age of a Player?

Hi, I would like a Text label to display the Account Age of a Player that is by a ImageLabel

1 comment

0

I updated my answer

1 answer

✓ Accepted answer

You can use the AccountAge property of Player. Simply set the text of the text label to the account age of the player, like this:

textlabel.Text = tostring(plr.AccountAge)

Edit: if you want to get the age of the player whose name you type in the textbox, you can do it like this if the player is in game:

local plr = game.Players:FindFirstChild(textbox.Text)
if plr then
	textlabel.Text = tostring(plr.AccountAge)
end

However if they are not in the game, you need to use HttpService along with some api. Feel free to use my api, however note that 000webhost will probably suspend my website again if people spam it too often.

local plr = game.Players:FindFirstChild(textbox.Text)
if plr then
	textlabel.Text = tostring(plr.AccountAge)
else
	local uid = game.Players:GetUserIdFromNameAsync(textbox.Text)
	local age = game:GetService("HttpService"):GetAsync("http://lolapis.000webhostapp.com/api/age/?id=" .. tostring(uid))
	textlabel.Text = age
end

4 comments

0

Not what I was really looking for. I want to enter the players name into a TExtBox then when I press search, the TextLabel will switch to the players age

0

no ^

0

There, updated my answer

0

It works, Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.