How can I access to the properties of variable defined in an previous routine?

OS (e.g. Win10): MacOS Ventura 13.4
PsychoPy version (e.g. 1.84.x): 2023.2.3
Standard Standalone? (y/n) y
What are you trying to achieve?: Using a variable defined in a previous routine

What did you try to make it work?: By using PsychoPy Builder, I create a first routine in which I have several variables including a button. I would like to access the number of times the button was clicked in a second routine but I cannot get these result. I saw that in the .csv file created by PsychoPy at the end of the experiment, I have the property button.numClicks with the corresponding number (which reading the code seems to be created at the end of the first routine) but I don’t know how recall this button property in the next routine.
Thanks for your help!

There’s a bug whereby button.numClicks is getting cleared at the end of the routine. Try setting a variable in End Routine e.g. buttonClicks = button.numClicks and then calling that. I tried to fix button.numClicks for the 2024.1.3 bugfix and got part way there but I think there might be a bit more to do. I haven’t had a chance to properly test it since our codesprint.

Thank you for your answer! I tried to initialize an empty variable n_click=None in ‘Begin Experiment’ and set it in EndRoutine as follows: n_click= button.numClick. However, when I call n_click in the second routine within a text variable ‘None’ appears, as if the final value of n_click had not been updated or saved at the end of the first routine.
I also attempted to not use button.numCliks by adding a conditional statement in each frame, that is:
if (mouse.isPressedIn(button)) {
chill_pressed = true;
n_click += 1;
and saving it in end routine but the result is the same as above.
I will keep trying and if you have any other suggestions you are welcome!