I want to make a very hectic game and one thing I would like to use would be an account age tracker. Basically it sees your account age and assigns you a specific amount of a currency called "Age".
How to assign a currency based on players account age?
3 answers
Hello NightWarrior!
Please keep in mind this script is not for you to copy word for word. Rather, it is to give you concept so you can accomplish what you're trying to do.
local Players = game:GetService('Players') --Gets the ROBLOX player service
Players.PlayerAdded:Connect(function(NewPlayer) --Fires whenever a new player joins the game
print('Well, look at that! ' ..NewPlayer.Name .. ' has joined the game! Their account age is ' ..NewPlayer.AccountAge)
end)
So, if I the user Builderman were to join a game, it would print out:
Well, look at that! Builderman has joined the game! Their account age is 5,292!
Keep in mind, the AccountAge is in days.
You can read up more on the ROBLOX Player.AccountAge property here.
In short terms, you'd want to detect when a new Player joined the game. Once the new player has joined the game, you'd want to get their AccountAge and change their leaderboard stat 'Age' value to their Player.AccountAge!
You should read up on ROBLOX In-game Leaderboards here!
Keep in mind the script above is untested, and may not work as it was written from memory. If this help you be sure to mark as the answer!
Good question, NightWarrior1717.
What you're trying to achieve is fairly simple! To get the age of a player's account (in days) you would use something like this:
local AccountAges = {} -- Empty table
Players = game:GetService("Players")
local function PrintTable(tab) -- This is just so we can print/read the contents of the table
for playerName, accountAge in pairs(tab) do
print(playerName..": "..accountAge)
end
end
Players.PlayerAdded:Connect(function(player)
local AccountAge = player.AccountAge
AccountAges[player.Name] = AccountAge
PrintTable(AccountAges)
end)
I recommend taking a look at these two articles:
Sure! You can use this script:
game.Players.PlayerAdded:Connect(function(player)
local accAge = player.AccountAge -- Gets player's account age
-- Creating leaderstats
local stats = Instance.new("Folder",player)
stats.Name = "leaderstats"
local age = Instance.new("IntValue",stats)
age.Name = "Age"
age.Value = accAge -- Sets the age value to the account age
end)
Each player has predefined properties and values, and AccountAge is one of them. However, this value is unchangeable.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Are you asking for the age of the account or the persons age thats is using the account?
.-. the account age