Counter thing (need help on scripting)

Hello, Its me, again.

  1. What do I want to achieve?
    I need to make a counter that increases every 0.7 seconds. And it decreases every 0.5s for 3 seconds by a click detector.

  2. What is the issue?
    The part where it increases worked, but the part where it decreases after clicking a button doesn’t work.

  3. What solutions have I tried so far?
    I tried using Boolean, Number, and String Values but got nowhere close to making it work.

Heres the script:

Maybe fix your loops comparison to tue.Value instead of just tue?

I tried that already. Picture’s outdated.

You want to move the event function above the loops, since code obviously run from top to bottom. Also try to make both loops into one, because the loops won’t work again once one deactivated.

-- button event above here
while true do
    if tue.Value == true then
        -- code
    else -- if tue.Value == false then
        -- code
    end
end