Here's a Roblox system that displays a player's join year in the leaderboard using Roblox's built-in leaderstats system:
🔧 Step-by-Step Setup
1. Create the Server Script
Place this script in ServerScriptService to fetch and display the join year:
-- ServerScriptService/JoinYearLeaderboard.lua
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
-- Create leaderstats folder for the player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
-- Create IntValue for the join year
local joinYearValue = Instance.new("IntValue")
joinYearValue.Name = "Join Year" -- Name shown in leaderboard
joinYearValue.Parent = leaderstats
-- Fetch the player's join date
task.spawn(function()
local success, joinDate = pcall(function()
return Players:GetUserJoinDateAsync(player.UserId)
end)
if success and joinDate then
-- Set the year as the value
joinYearValue.Value = joinDate.Year
else
-- Fallback if API fails
joinYearValue.Value = 1999 -- Unknown year
end
end)
end)
🎮 What This Does
leaderstats Folder: Automatically recognized by Roblox for leaderboard display.
IntValue Named "Join Year": Displays the year the player joined (e.g., 2015).
GetUserJoinDateAsync(): Fetches the player's join date as a DateTime object.
- Error Handling: Uses
pcall to avoid crashes if the API fails.
📝 Notes
- Ensure leaderstats are enabled in your game settings:
- Go to
File > Game Settings > General
- Check "Generate leaderstats for new players".
- The leaderboard will show:
Join Year: 2015 Points
(Roblox always appends "Points" to numeric values in leaderstats).
🧩 Optional: Customize Display
If you want a cleaner format like "Joined: 2015":
Use a StringValue and Custom Leaderboard GUI
This requires overriding the default leaderboard UI with a ScreenGui. Let me know if you want this advanced version!
✅ Example Output in Leaderboard
| Player | Join Year |
|---|
| User123 | 2018 |
| CoolPlayer | 2021 |
Let me know if you want to include the full date (e.g., Jan 2018) or style it differently!