So I’m making a surface GUI and I wanted to know how to add player info to it. Like how many days the player has had the account. join date. players name?
I don’t want it to show other players info for other people. like If player 1 joins the surface gui shows player 1s info. and if player 2 joins the surface gui shows player 2s info but for their screen only. So client only.
You can use a Local Script to only show it to the player.
And you probably should learn about this:
https://developer.roblox.com/en-us/api-reference/class/Player
Local scripts are definitely your friend for this
You can do http requests to get the info and use LocalScript’s and RemoteEvent’s to make the info only shown to 1 player.
Here’s a example:
local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local userId = 1
local data = HttpService:GetAsync("https://users.rprxy.xyz/v1/users/" .. userId)
wait(2)
ReplicatedStorage.SendPlayerInfo:FireClient(game.Players:GetPlayers()[1], data)
game:GetService("ReplicatedStorage").SendPlayerInfo.OnClientEvent:Connect(function(data)
-- show data here
end)
Edit: Use ozyubkx’s solution instead
I would recommend using os.date and player.AccountAge to calculate join date, and player.Name for player name. If you need any other info just look at the Player class reference (sent by first reply). I would use http requests as a last resort since there is a limit to amount you can send per minute and it’s just slower.
example:
print(os.date("%Y-%m-%d", os.time() - game.Players.LocalPlayer.AccountAge * 86400))
prints localplayer join date
Question. I don’t know much about Os.Date but what do the numbers at the end mean?:
86400
amount of seconds in a day since AccountAge is in days and os.date works with seconds