Get only 1 decimal

Basically I am trying to make a cooldown and i want it to show like 5.5 sec not only 5 sec
but when i do my cooldown it can only either show like 10 decimals(5.592859429) or 0 decimal(5). How would i go about getting 1 decimal for my cooldown.

Take anime Dimensions for example,their cooldown is whole numbers plus 1 integer

Use the % specifier along with the f specifier, along with other formats:

print(("%.1f"):format(10.50123)) --> 10.5
4 Likes

what does this do, I’d never seen this before

We’ll be using pi as a reference.

You can do

local newNum = string.sub(3.14159, 1, 2).
print(newNum)
2 Likes

Yes it may be slower, however I just optimized it to how much the person that made this topic knew and wanted to give a simple and easy to understand solution.

1 Like