In my game I want there to be a character created value in a stat menu.
Example:
This is just placeholder text however and it doesn’t work.
Whats the best way to figure out when a players character was made? I was thinking something to do with tick() or os.time() all help is greatly appreciated!
You could track the start time (when the player first creates the character) in a table and then save that to a datastore. Then every time they reset/leave the game, you can add the current time onto the variable.
Something like this:
local player --the player
local playTime = {} --table to hold player in-game time
--initializing the time when they first create the character
playTime[player] = {
initialTime = workspace:GetServerTimeNow(),
totalPlayTime = 0,
}
---below is for when you reset/leave the game, to update the time
playTime[player].totalPlayTime += (workspace:GetServerTimeNow() - playTime[player].initialTime)
Also remember to set initialTime to workspace:GetServerTimeNow() every time the player spawns into the game, so you can track for that session
I wasn’t referring to playtime but rather the actual time the character was made.
Example: I make a character and only play for 1 hour then log off for a week and come back. The time should say Character Created: 1 Week Ago
Ohhh that’s even easier to do. Just track whenever the player created the account using workspace:GetServerTimeNow() then save that value. And when you want to display when it was created, just retrieve that stored value and do print(workspace:GetServerTimeNow() - storedInitialTime) where stored initial time is the saved value from when it was created