I’m currently working on a Battle Cats inspired game, and I added a countdown-esc cooldown UI to prevent spam when spawning units, as shown here.
I also wanted for my cooldown to display tenths of a decimal, but I used the “for i = etc.” for the number countdown, which doesn’t really pair well with decimals from what I know of.
Any way I could add tenths to the countdown? Thanks!
local start = tick()
while true do
wait()
local diff = tick() - start
print(diff, "seconds has passed since the start")
local min = math.floor(diff / 60)
local sec = diff - min*60
local mil = math.floor((sec - math.floor(sec)) * 10) -- doing 7.123 - 7 gives us 0.123, then multiply by 10 and floor to get just 1
sec = math.floor(sec)
print(min .. ":" .. sec .. ":" .. mil, "total time has passed")
end
I played around with this script a bit and I got some stuff down, but I can’t seem to figure out how to make it count down instead of up. Any suggestions?
for i = cd,0 do
AbilityDisplay.MainFrame[m].CooldownDisplay.Text = "Cooldown: "..i
wait(1)
end
for their cooldown that went down without decimals and just seconds originally before knowing how to add decimals like me, make sure to change the wait(1) to wait(1 / 10) because the decimals when go down every seconds which im not sure is what you would want
REFERENCE OLD:
for i = (cd * 10),(0 * 10),-1 do
AbilityDisplay.MainFrame[m].CooldownDisplay.Text = "Cooldown: "..(i/10)
wait(1)
end
REFERENCE NEW:
for i = (cd * 10),(0 * 10),-1 do
AbilityDisplay.MainFrame[m].CooldownDisplay.Text = "Cooldown: "..(i/10)
wait((1 / 10))
end