Timer that counts upwards instead of counting downwards

No no. You don’t make timers with a for loop, very bad practice. This is a better solution:

local start = os.clock()

textLabel.Text = os.clock()-start

Doing a timer with a for loop would mean that the time goes slower with lag and it uses up too much memory.

Will that format it with the hours and seconds?

local startTime = os.clock()

local TextLabel = script.Parent
local BoolVal = game.ReplicatedStorage:WaitForChild("Touched")

local function sToHMS(s)
    local h = math.floor(s/3600)
    s = s % 3600
    local m = math.floor(s/60)
    s = s % 60
    return string.format("%02i:%02i:%02i", h, m, s)

    if BoolVal.Value then return end
    TextLabel.Text = sToHMS(os.clock() - startTime)

Alternating @XdJackyboiiXd21’s script and keeping @iamtryingtofindname’s point in mind, I came up with this. I guess you could try it out, I didn’t test it myself in Studio.

Edit: Forgot to do the string.format(), the actual reason why I wrote the post :man_facepalming:

1 Like

Why did you do if bool.Value then break end, did you mean return end?

1 Like

No, you are supposed to do that on your own, but your way is very unreliable

This was the code that worked in my position. Thank you for solving the problems for the other devs participating and spending their time to help me out.
Well done! :+1:

How would you be able to reset this?

Change the startTime back to os.clock() (current time).

Ah, thank you for the solution.
Much appreciated!