# Edit text in a local script help*

Hello i have the number 1.35999999999
i want to make the number into 1.35 (clear all the numbers after the first 3 numbers
^
the above is an example of a simplified version of my overall issue.

1 Like

Depends on if you want to use the rounded version for only displaying on the screen or if you want to it use in any other parts of your code

If itâ€™s just for display you can do `string.format("%.2f", number)` where `number` is your number, this will only display up till the first 2 decimals

If youâ€™re planning on using it for other parts of your code, multiply it by 100, floor it and divide by 100 again

``````math.floor(number * 100) / 100
``````
2 Likes

it removes the dot in numbers like 1.359999 and would be just
135 which is not desirable at all

i tried this and it rounded the numbers up to the ones place.
for example it would turn 1.3599 into 1 but i want it to turn 1.3599 into 1.35 not 1

by the way the number is always going to be 1 digit in my case

(im making a timer that goes to 2 and im using a for loop to count up miliseconds but its addings lots of extra things for some reason so ill just edit the extra stuff out)

code:

``````for i=2,0,-0.1 do
local edittedI = tonumber(string.format("%2.f", i))
One.TextLabel.Text = tostring(edittedI)
end
``````

(current code rounds 1.35 to just 1)

I think you meant to do

``````tonumber(string.format("%.2f", number))
``````

Though this causes rounding, so if @OP has `1.356577`, it becomes `1.36`, I think the solution @OP needs is this

``````math.floor(number * 100) / 100
``````

As this wonâ€™t round the number, though not sure how he got `135`, I think they forgot to divide by 100 afterwards?

2 Likes

You seem to only be using it for displaying, in that case canâ€™t

``````local edittedI = tonumber(string.format("%2.f", i))
One.TextLabel.Text = tostring(edittedI)
``````

Become

``````One.TextLabel.Text = string.format("%.2f", i)
``````

I am not sure where 1.35 is coming from in that code, your for loop decrements in intervals of 0.1

Thatâ€™s not really Robloxâ€™s fault, itâ€™s a fault with how decimal precision is when doing any decimal arithmetic sometimes

itâ€™s roblox being gay. They want to be quirky with adding an extra 0.00000001 to my interval of 0.1 for loops

``````math.floor(number * 100) / 100
``````

works though

1 Like