#timer problems

1 messages · Page 1 of 1 (latest)

floral folio
#

so im trying to make it that the timer stops whenever i stop holding down left shift but all it does is reset the timer (like it should) and it wouldent stop (what is shouldent do) any help would be very welcoming

jolly crypt
#

try it

#
local plr = game.Players.LocalPlayer
local char = plr.Character

local machtime = 10
local machcooldown = false
local timerCoroutine

local function startTimer()
    while machtime > 0 and machcooldown do
        machtime = machtime - 1
        print(machtime)
        wait(0.5)
    end
end

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift and not machcooldown then
        machcooldown = true
        timerCoroutine = coroutine.create(startTimer)
        coroutine.resume(timerCoroutine)
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift and machcooldown then
        machcooldown = false
        machtime = 10
        print(machtime)
        print("mach reset (slowpoke)")
    end
end)
floral folio
#

ok il see thanks btw