# TypeError: undefined is not an object (evaluating 'win.\_psychoJS')

**URL:** https://discourse.psychopy.org/t/typeerror-undefined-is-not-an-object-evaluating-win-psychojs/43979
**Category:** Online experiments
**Tags:** pavlovia
**Created:** [February 20, 2025, 11:03am UTC](https://discourse.psychopy.org/t/typeerror-undefined-is-not-an-object-evaluating-win-psychojs/43979 "2025-02-20T11:03:33Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [February 20, 2025, 11:56am UTC](https://discourse.psychopy.org/t/typeerror-undefined-is-not-an-object-evaluating-win-psychojs/43979/2 "2025-02-20T11:56:25Z")

</div>

It’s how you’re defining “score\_text” in a code block.

The best solution in my opinion would be to make an actual text component in the builder for score\_text and either update it’s content (`score_text.text = 'Score: ${score}'`) or its visibility (`score_text.autoDraw(false)` at the beginning of the routine and `score_text.autoDraw(true)` when you want it to appear).

The basic issue is that you define it this way:

```auto
    score_text = new visual.TextStim(psychoJS.window, 
    {"text": `Score: ${score}`, 
    "pos": [0, 0.4], 
    "height": 0.05, 
    "color": "black"});

```

but if you really want to define it in a code block, it needs to look like this:

```auto
    score_text = new visual.TextStim(
    {"win":psychoJS.window, //this is the important change
    "text": `Score: ${score}`, 
    "pos": [0, 0.4], 
    "height": 0.05, 
    "color": "black"});

```

But again, I think it’d be easier to just make it a normal text component in the builder and control its content or appearance with the code component.

---

_[View the full topic](https://discourse.psychopy.org/t/typeerror-undefined-is-not-an-object-evaluating-win-psychojs/43979)._
