Hey im trying to display a IntValue (with a text label) with a NumberValue How do i do that. I dont want it to display decimals but i need decimals to add some features.
As the comments say, use math.floor()
.
math.floor(num)
returns num
in its truncated form (to truncate a number means to chop off the decimal point, which means that 3.95 would become 3). math.ceil(num)
(which is what you shouldn't use) returns the 'raised' form of num
to the next integer. (You should not use this because math.floor()
can do this. I'm about to show you how.)
If you want to round a number, then use math.floor(num + 0.5)
. Do not use math.ceil()
.
Demonstration:
print(math.floor(3.2 + 0.5)) -- Prints 3 because 3.2 + 0.5 = 3.7 print(math.floor(3.6 + 0.5)) -- Prints 4 because 3.6 + 0.5 = 4.1