Can someone explain how to make timer by using tick() or os.clock()?
I was trying to make timer by using os.clock() but here is what prints in output.
here is script:
local BoostStart = os.clock()
local BoostLength = 120
local BoostEnd = BoostStart + BoostLength
for i = 1, BoostLength do
print(BoostEnd - i)
wait(1)
end
os.clock should only be used for benchmarking, it refers to the CPU clock cycles.
You’re code example shouldn’t use this but if you want a wall-clock timestamp use os.time().
Here’s what I think you want, but there are still better alternatives depending on what you are trying to do.
local BoostLength = 120
for i = 1, BoostLength do
local remaining_time = BoostLength - i
print(remaining_time)
task.wait(1) -- task.wait is usually more accurate than wait
end