# Skip next routine when 1 of 2 buttons is clicked

**URL:** <https://discourse.psychopy.org/t/skip-next-routine-when-1-of-2-buttons-is-clicked/38141>\
**Category:** Builder\
**Tags:** buttons\
**Created:** [January 9, 2024, 11:48pm UTC](https://discourse.psychopy.org/t/skip-next-routine-when-1-of-2-buttons-is-clicked/38141 "2024-01-09T23:48:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emily\_Stekl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/emily_stekl/32/40447_2.png) [@Emily\_Stekl](https://discourse.psychopy.org/u/Emily_Stekl)\
**Post date:** [January 9, 2024, 11:48pm UTC](https://discourse.psychopy.org/t/skip-next-routine-when-1-of-2-buttons-is-clicked/38141/1 "2024-01-09T23:48:28Z")

</div>

**OS** (e.g. Win10): Windows 11  
**PsychoPy version** (e.g. 1.84.x): 2023.2.3

**What are you trying to achieve?:**  
My experiment is a traditional Old/New Recognition Test. In my old/new routine, I have two button components (named ‘button’ for Old and ‘button\_2’ for New). If button (old) is selected, participants will move onto the next routine (named source) asking where they have previously seen the image. However, if button\_2 (new) is pressed, I want to skip the next routine (source) and continue on with the loop.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/3/33ef9564c3bf0c300793c6ed4a03b7ca2fdd2762.png)

**What did you try to make it work?:**  
For this I tried: in the Each Frame of the code component

if button\_2.contains(mouse) and mouse.isPressedIn(button\_2):  
button\_2\_clicked = True  
if button\_2.contains(mouse) and mouse.isPressedIn(button):  
button\_2\_clicked = False

I’m not sure if I need to put something into the End Routine of this code component OR  
Add a code component to the next routine (source) and in Begin Routine have:  
if button\_2\_clicked:  
continueRoutine = False

I’m brand new to PsychoPy and know nothing about python, so I’m in the dark here. I was going back and forth with ChatGPT for a while, but it’s using the 2022 version of psychopy and I was running into errors.

**What specifically went wrong when you tried that?:**  
The source routine is not skipped when button\_2 is pressed.
