How to make a day:hrs:min:sec clock to count how long the player has played

I have a h:m:s timer, but i’m trying to make a d:h:m:s timer because the hours, after they reach 24, they stack back to 00:00:00.

this is what i have so far:

game["Run Service"].RenderStepped:Connect(function(ticks)
	local player = game.Players.LocalPlayer
	
	local function FormatSeconds(x: number): string
		return os.date("!%X", x)
	end
	local Seconds = FormatSeconds(player:WaitForChild("TotalTime").Value)
	script.Parent.Text = Seconds
end)

I found this function code somewhere a while ago (can’t remember when or where)

function FormatSeconds(seconds)

	local secondsLeft = seconds
	local days = math.floor(secondsLeft/86400)
	local hours = math.floor((secondsLeft % 86400)/3600)
	local minutes = math.floor(((secondsLeft % 86400) % 3600)/60)
	local seconds = math.floor((((secondsLeft % 86400) % 3600)%60)/1)
	local TimeLeft = string.format("%id %02ih %02im %02is", days, hours, minutes, seconds)

	return TimeLeft

end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.