How do I make a detailed timer?

Hey there! I’m wondering how to make a detailed timer for my game such as this one:


without it lagging at all. How can I do this without issues? I’ve tried using wait() in a loop but that doesn’t work well (it lags!).

Thanks for your help,
Ralph.

local start = os.clock()

function round(num, decimalDigits)
	local x = 10^decimalDigits 
	return math.round(num*x)/x
end

--changing the loop wait wont effect the timer.
while task.wait() do
	local current = os.clock() 
	local result = round(current-start, 3) 
	print(result)
end