I have this cooldown GUI which represents the cooldown of your gadget. It represents the cooldown in tenths, so it would go down like 8.9, 8.8, 8.7… which works perfectly fine. But I just want to add something to make it look a little bit nicer. If I get a whole number, instead of, for example, 5, I want it to say 5.0 instead. I tried searching for solutions but I’m not sure what to search up as this is kind of specific. Thanks for the help!
This might not be the best solution, but:
if math.floor(number)==number then
text ..= ".0"
end
Assuming you set text to tostring(number).
You’ll want to use string.format
string.format("%.1f", [Countdown Number Here])
3 Likes
local seconds = 10
for i = 0, seconds*10 do
if ((i-10)%10 == 0) then
print(10-(i*.1)..".0")
else
local num = 10-(i*.1)
print(math.round(num*10)/10)
end
wait(.1)
end
10.0 - Server - Script:4
9.9 - Server - Script:4
...
3.0 - Server - Script:4
2.9 - Server - Script:7
2.8 - Server - Script:7
2.7 - Server - Script:7
2.6 - Server - Script:7
2.5 - Server - Script:7
2.4 - Server - Script:7
2.3 - Server - Script:7
2.2 - Server - Script:7
2.1 - Server - Script:7
2.0 - Server - Script:4
1.9 - Server - Script:7
1.8 - Server - Script:7
1.7 - Server - Script:7
1.6 - Server - Script:7
1.5 - Server - Script:7
1.4 - Server - Script:7
1.3 - Server - Script:7
1.2 - Server - Script:7
1.1 - Server - Script:7
1.0 - Server - Script:4
0.9 - Server - Script:7
0.8 - Server - Script:7
0.7 - Server - Script:7
0.6 - Server - Script:7
0.5 - Server - Script:7
0.4 - Server - Script:7
0.3 - Server - Script:7
0.2 - Server - Script:7
0.1 - Server - Script:7
0.0 - Server - Script:4
Even better is to turn your code into a function or module so you can re-use it easier
string.format is a function, wrapping it inside of another function would just decrease performance.