Answered by
8 years ago Edited 8 years ago
To fix this, simply round your number.
1 | script.Parent.Text = math.floor(brightness.Brightness + . 5 ) |
math.floor
function rounds a decimal down.
+.5
because a decimal should only be rounded down if it's below .5 --> adding .5 makes it so if the number was per say 4.55, then it would change to 5.05 and be rounded down to 5
If you don't want it to round full numbers, you can multiply the Brightness by 10^x
, where x is your decimal place, then divide it by the same factor on the outside of the floor function.
2 | script.Parent.Text = math.floor((brightness.Brightness* 10 )+. 5 )/ 10 |
Here's a neat function for rounding to specified decimal places :)
1 | function round(num,place) |
2 | local divisor_and_factor = 10 ^place; |
3 | return math.floor((num*divisor_and_factor)+. 5 )/divisor_and_factor; |
7 | script.Parent.Text = round(brightness.Brightness, 2 ); |