Suspend function

In my game, I am trying to suspend this function when a colission takes place.  Could anyone please help me out?

– Variables
local currentScore= 0
local scoreTxt = display.newText( "Score: "…currentScore , 100, 200, native.systemFont, 16 )
scoreTxt:setFillColor( 1, 0, 0 )

– Listener for your timer, updates score variable and updates the text
local function scoreKeeper( event )
    currentScore = currentScore + 1
    scoreTxt.text = "Score: "…currentScore
end
 
 timer.performWithDelay( 2000, scoreKeeper, -1 )
 

The timer.performWithDelay function returns a handle that you can use to pause or stop timers.

local timerHandle

timerHandle = timer.performWithDelay( 2000, scoreKeeper, -1)

Then later when you want to cancel the timer, do:

timer.cancel(timerHandle)

Rob

Then after I do that, how can I restart the timer?

timerHandle = timer.performWithDelay( 2000, scoreKeeper, -1)

when you want to restart it.

The timer.performWithDelay function returns a handle that you can use to pause or stop timers.

local timerHandle

timerHandle = timer.performWithDelay( 2000, scoreKeeper, -1)

Then later when you want to cancel the timer, do:

timer.cancel(timerHandle)

Rob

Then after I do that, how can I restart the timer?

timerHandle = timer.performWithDelay( 2000, scoreKeeper, -1)

when you want to restart it.