ReferenceError: starterClock is not defined

Dear Community,

After exporting my Builder experiment to JS to pilot it in Pavlovia, the online run crashes after the experiment setup window with:

ReferenceError: starterClock is not defined

I can see starterClock.reset() in the auto‑generated template, but there’s no preceding var starterClock; / starterClock = new util.Clock(); in the file. Adding a dummy invisible component to the routine and re‑exporting, or manually inserting var starterClock;, didn’t fix it—the error persists. I have tried multiple other things, including using different PsychoPy versions, checking the experiment for any accidental custom code referencing starterClock initialization etc. In previous versions of the task, the variable was automatically declared, so I am not sure why it isn’t in my current script.

I am still new to PsychoPy and would be super grateful for any advice. I am using MacOS, PsychoPy Builder Version 2024.2.4 Py 3.8, experiment settings: Use PsychoPy version 2023.2.3.

URL: Social Decision Game LD4 [PsychoPy]

The link you provided doesn’t work. Can you provide the github link instead?

The starterClock variable is coming from a routine named “starter”. If it isn’t initialized, you might have created said routine, and then removed it at some point. The starterClock variable should be initialized prior to the start routine, and the starterClock = new util.Clock() should be in the same places as in this photo:

If that doesn’t work, try creating a new builder experiment and copy and paste each routine (and objects in said routine) to the new experiment.
Issac

Thank you, Isaac! I had to create a new builder experiment and copy and paste each routine. I noticed that when I declared a specific variable in JS locally using let or const, it must have overwritten any of Builder’s own JS var declarations.