Converting long minute number to "#.#"

I’m making a system for my game where it divides a certain amount of seconds by 60 and it gives a decimal minute time. e.g 3.4 minutes

By doing this, sometimes it returns a number like 1.1666666666667 or similar. How would I convert any number that returns a value like this to 1.1 or #.#?

1 Like

You could use string.format for this.

local str = string.format("%.1f", somethingHere)
print(str)

This basically takes in the number and spits out a string with only 1 decimal. If you’d want it to be 2 decimals then you would change the 1 to be 2.

1 Like