How to limit the number of displayed numbers after point?

Hi,
I have this script:

Timer.Text = "Access granted ("..tostring(60-((DateTime.now().UnixTimestampMillis/1000)-accessGrantedTime))..")"

and it makes the timer show numbers like 49.42893675427652
I know why it’s happening but I don’t know how to make it show less numbers after point (3 for me), for example convert 24.32847 to 24.328

Can someone help?

This is a function that should do just that:

local function RoundDecimals(whole:number, NumberOfDecimals:number)
	local multiplier = 10 ^ NumberOfDecimals
	
	return math.round(whole*multiplier) / multiplier 
	
end
1 Like