Experiment shuts down when moving the finger on the screen

I have a trouble with my experiment. My experiment is run on a big sensor screen so that participants touch the stimuli with their hand. To start the trial, they need to press the screen for at least 2 seconds. Straight after that the hear a sound, take off the finger and touch the screen in a different place. The problem is that if they move their finder even a little when pressing the screen, the experiment shuts down and the following error occurs:

Line 361, in if t - buttonPressTime >= 2: # button has been held down for at least 2 seconds
TypeError: unsupported operand type(s) for -: ‘float’ and ‘list’

What should I do so that experiment works properly. You can see my code below. Thank you for your assistance.

— Prepare to start Routine “centralpress” —

continueRoutine = True
routineForceEnded = False
# update component parameters for each repeat
# setup some python lists for storing info about the mouse
mouse.x = []
mouse.y = []
mouse.leftButton = []
mouse.midButton = []
mouse.rightButton = []
mouse.time = []
mouse.release_time = []
mouse.release_pos = []
buttonPressTime = []
buttonReleaseTime = []
clickHistorycentralpress = []

gotValidClick = False  # until a click is received
# Run 'Begin Routine' code from code
mouserec=mouse.getPos()
minRT = .2

# keep track of which components have finished
centralpressComponents = [polygon, polygon_2, mouse]
for thisComponent in centralpressComponents:
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
frameN = -1

# --- Run Routine "centralpress" ---
while continueRoutine:
    # get current time
    t = routineTimer.getTime()
    tThisFlip = win.getFutureFlipTime(clock=routineTimer)
    tThisFlipGlobal = win.getFutureFlipTime(clock=None)
    frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
    # update/draw components on each frame
    
    # *polygon* updates
    if polygon.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
        # keep track of start time/frame for later
        polygon.frameNStart = frameN  # exact frame index
        polygon.tStart = t  # local t and not account for scr refresh
        polygon.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(polygon, 'tStartRefresh')  # time at next scr refresh
        # add timestamp to datafile
        thisExp.timestampOnFlip(win, 'polygon.started')
        polygon.setAutoDraw(True)
    
    # *polygon_2* updates
    if polygon_2.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
        # keep track of start time/frame for later
        polygon_2.frameNStart = frameN  # exact frame index
        polygon_2.tStart = t  # local t and not account for scr refresh
        polygon_2.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(polygon_2, 'tStartRefresh')  # time at next scr refresh
        # add timestamp to datafile
        thisExp.timestampOnFlip(win, 'polygon_2.started')
        polygon_2.setAutoDraw(True)
    # *mouse* updates
    if mouse.status == NOT_STARTED and t >= 0.0-frameTolerance:
        # keep track of start time/frame for later
        mouse.frameNStart = frameN  # exact frame index
        mouse.tStart = t  # local t and not account for scr refresh
        mouse.tStartRefresh = tThisFlipGlobal  # on global time
        win.timeOnFlip(mouse, 'tStartRefresh')  # time at next scr refresh
        # add timestamp to datafile
        thisExp.addData('mouse.started', t)
        mouse.status = STARTED
        mouse.mouseClock.reset()
        prevButtonState = mouse.getPressed()  # if button is down already this ISN'T a new click
    if mouse.status == STARTED:  # only update if started and not finished!
        buttons = mouse.getPressed()
        if buttons != prevButtonState:  # button state changed?
            prevButtonState = buttons
            if prevButtonState[0]:  # button is down
                buttonPressTime = t  # record the time the button was pressed
            else:  # button is up
                buttonReleaseTime = t  # reset the button press time
        elif prevButtonState[0]:  # button is still down
            if t - buttonPressTime >= 2:  # button has been held down for at least 2 seconds
                
                x, y = mouse.getPos()
                mouse.x.append(x)
                mouse.y.append(y)
                clickHistorycentralpress.append({"timeStamp1": core.getTime(), "position1": mouserec})
                buttons = mouse.getPressed()
                mouse.leftButton.append(buttons[0])
                mouse.midButton.append(buttons[1])
                mouse.rightButton.append(buttons[2])
                mouse.time.append(mouse.mouseClock.getTime())
                continueRoutine = False  # abort routine on respons
    
    
    # check for quit (typically the Esc key)
    if endExpNow or defaultKeyboard.getKeys(keyList=["escape"]):
        core.quit()
    
    # check if all components have finished
    if not continueRoutine:  # a component has requested a forced-end of Routine
        routineForceEnded = True
        break
    continueRoutine = False  # will revert to True if at least one component still running
    for thisComponent in centralpressComponents:
        if hasattr(thisComponent, "status") and thisComponent.status != FINISHED:
            continueRoutine = True
            break  # at least one component has not yet finished
    
    # refresh the screen
    if continueRoutine:  # don't flip if this routine is over or we'll get a blank screen
        win.flip()

# --- Ending Routine "centralpress" ---
for thisComponent in centralpressComponents:
    if hasattr(thisComponent, "setAutoDraw"):
        thisComponent.setAutoDraw(False)

thisExp.addData('clickHistorycentralpress', clickHistorycentralpress)

# store data for trials (TrialHandler)
trials.addData('mouse.x', mouse.x)
trials.addData('mouse.y', mouse.y)
trials.addData('mouse.leftButton', mouse.leftButton)
trials.addData('mouse.midButton', mouse.midButton)
trials.addData('mouse.rightButton', mouse.rightButton)
trials.addData('mouse.time', mouse.time)
trials.addData('buttonPressTime', buttonPressTime)
trials.addData('buttonReleaseTime', buttonReleaseTime)
# the Routine "centralpress" was not non-slip safe, so reset the non-slip timer
routineTimer.reset()

You cannot subtract a list (in this case, an empty list) from a float. It doesn’t make sense in this case.
In this scenario, your list is also empty, so even if you tried picking the first item in the list, it doesn’t exist.
Do you set the buttonPressTime anywhere else?