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

How would I get the Account Age of a Player?

Asked by 5 years ago

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

0
I updated my answer Amiaa16 3227 — 5y

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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
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 Trooper_Toaster 0 — 5y
0
no ^ User#24403 69 — 5y
0
There, updated my answer Amiaa16 3227 — 5y
0
It works, Thanks Trooper_Toaster 0 — 5y
Ad

Answer this question