# Pause code does not work in online experiment

**URL:** https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315
**Category:** Online experiments
**Tags:** pavlovia
**Created:** [April 13, 2020, 10:01am UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315 "2020-04-13T10:01:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Mel499](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mel499/32/6581_2.png) [@Mel499](https://discourse.psychopy.org/u/Mel499)
#### Post date: [April 13, 2020, 10:01am UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315/1 "2020-04-13T10:01:44Z")

</div>

URL of the experiment: [https://run.pavlovia.org/Mel499/animals\_semantic-discrimination/html/?\_\_pilotToken=d3d9446802a44259755d38e6d163e820&\_\_oauthToken=8394ed62a7ad69a61ade176e43a234bdd243c0d84b15a7801ae4547fea1b738f](https://run.pavlovia.org/Mel499/animals_semantic-discrimination/html/? __pilotToken=d3d9446802a44259755d38e6d163e820&__ oauthToken=8394ed62a7ad69a61ade176e43a234bdd243c0d84b15a7801ae4547fea1b738f)

Description of the problem:

I designed the experiment with psychopy3 on my computer in the way that after half of the trials, there should be a short break. Therefore, within the “trials”-loop, I added a routine “pause” that should only occur if the number of trials is “150” (in total, there are 300 trials). I did this by adding the following code to the “Pause”-Routine (In the “Begin Routine” part):

if trials.thisN != 150:  
continueRoutine = False

On my computer, this works perfectly fine and after 150 trials, the “Pause” Routine occurs once with the relevant text. However, if I try the experiment online on Pavlovia, the “Pause” Routine occurs after every single trial.

Do you have any idea why that is and how I could change it?

---

<div class="post-metadata">

### Author: ![phoenix](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@phoenix](https://discourse.psychopy.org/u/phoenix)
#### Post date: [April 13, 2020, 12:50pm UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315/2 "2020-04-13T12:50:11Z")

</div>

The URL to your experiment is not public so I cannot access it.  
What you mention is a known issue when running experiments online since Auto-JS translation doesn’t seem to work in such cases. Could you please post your code component window to see how this is translated into JS?

---

<div class="post-metadata">

### Author: ![Mel499](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mel499/32/6581_2.png) [@Mel499](https://discourse.psychopy.org/u/Mel499)
#### Post date: [April 13, 2020, 1:03pm UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315/3 "2020-04-13T13:03:11Z")

</div>

Sure, this is the code component window:

 ![Bildschirmfoto 2020-04-13 um 14.56.51](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/d/bdaf1fe8dc0e52a96cabce30a321b7c5f6e6daf9.jpeg)

I’ve tried to change the code type from Auto-\>Js to Js, but it still doesn’t work. Do you know which type of code would work in online experiments?

---

<div class="post-metadata">

### Author: ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)
#### Post date: [April 13, 2020, 1:25pm UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315/4 "2020-04-13T13:25:12Z")

</div>

Try trials.thisTrialN instead of trials.thisN.

See here: ["Take a break" works locally but not online](https://discourse.psychopy.org/t/take-a-break-works-locally-but-not-online/11785/6)

---

<div class="post-metadata">

### Author: ![Mel499](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/mel499/32/6581_2.png) [@Mel499](https://discourse.psychopy.org/u/Mel499)
#### Post date: [April 13, 2020, 1:46pm UTC](https://discourse.psychopy.org/t/pause-code-does-not-work-in-online-experiment/12315/5 "2020-04-13T13:46:35Z")

</div>

Thank you so much for your help!  
In the end, it worked when I moved the code from the “begin routine” to the “every frame” window, as was suggested in the other discussion that you linked here.
