Multiple clicks don't work in loop

OS (e.g. Win10):
**PsychoPy version 2022.2.5:

What are you trying to achieve?: Hi. I am programming an experiment in PsychoPy Builder. The task is to match images according to a pattern (e.g. dog to dog, flower to flower and car to car). The task is to match pictures according to a pattern (e.g. dog with dog, flower with flower and car with car). In each trial there are 3 images, a “model” image that appears at the top-centre, a distractor image and a target image (appearing at the bottom and to the right or left). Therefore, it is composed of a routine in which 3 image components (M_stim, D_stim and L_stim) associated to a series of images from an excel file with 3 parameters (model_stim, der_stim, izq_stim) appear in a loop. I have included a mouse component to move from one trial to another but I need the participant to click on 2 image components to finish the routine as explained below: first click on M_stim. Only if he clicks on M_stim a second click can be made. In the second click, I want you to be able to click on both D_stim and L_stim and thus finish the routine, no matter which one you click on. This is the only way to move on to the next trial in the loop. How can I do this?

What did you try to make it work?: I tried this youtube tutorial (Using Multiple Mouse Clicks in One Trial in PsychoPy 🖱️ - YouTube) but the code only works if you make separate routines. When you apply it in a routine associated to a loop it randomizes the 2 images that you have to click in each trial, so you have to find which ones they are, and that doesn’t work for me.

I’m currently testing with another code, too, but it passes from item to item when clicking on only one image component, no matter which one.

Begin Routine:
click_count = 0

Each Frame:

if mouse.isPressedIn(M_stim):
click_count += 1

if click_count == 1 and mouse.isPressedIn(D_stim) or mouse.isPressedIn(L_stim):
continueRoutine = False

What is wrong or how can I fix it?

PsychoPy Documents link: PsychoPy - Google Drive