Code working in some routines, but not others

I have three routines that are extremely similar, so much of their code is the same. The first is a practice round, the second are basic trials and the third more challenging trials. The code works great in both the practice and challenge routines, but is causing the basic routine to be skipped altogether. I discovered this by disabling codes until the routine would work again. I cannot figure out why the code isn’t working. The name of the mouse and message are correct. What other reason could cause this code to be the reason the routine is skipped? I am getting no error message, it is just skipping the routine. All three codes are in their respective Each Frame tabs. Here are the codes:

Practice

if mouse_prac.isPressedIn(Done_prac, buttons=[0]) and msgp=='success':
    messp = 1
    continueRoutine = False

elif mouse_prac.isPressedIn(Done_prac, buttons=[0]) and msgp != 'success':
    messp = 0
    continueRoutine = False 

Challenge

if mouse_resp9.isPressedIn(Done_9, buttons=[0]) and msg9=='success':
    mess9 = 1
    continueRoutine = False

elif mouse_resp9.isPressedIn(Done_9, buttons=[0]) and msg9 != 'success':
    mess9 = 0
    continueRoutine = False

Basic Code (causing this routine to be skipped)

if mouse_resp.isPressedIn(Done_4, buttons=[0]) and msg4=='success':
    mess4 = 1
    continueRoutine = False

elif mouse_resp.isPressedIn(Done_4, buttons=[0]) and msg4 != 'success':
    mess4 = 0
    continueRoutine = False

Thank you

And specify what tab the code is in.

Thank you

I fixed it. I moved the code to the End Routine tab. Not sure why it worked for 2/3 in the Each Frame tab, but it’s working for all of them now.

OK, but note that setting continueRoutine = False has no effect in the End Routine tab. By definition, that variable is already False, which is why the End Routine code is being executed.

Right. I’ll delete that, thank you. I’m still baffled by what the problem was, though. That code was the very last thing in the Each Frame tab. Shouldn’t everything have run, and then crashed or ended when it got to that code, rather than skipping the routine altogether? Everything is working perfectly in that routine now.

We can’t tell without seeing more, but the most likely explanation is that the mouse click that ended the routine prior to your basic trial was in the same place as the target stimulus you are testing for on the basic trial itself, so the same click ended two routines almost immediately.