# 'This.scene is undefined'

**URL:** <https://phaser.discourse.group/t/this-scene-is-undefined/6188>\
**Category:** Phaser 3\
**Created:** [May 4, 2020, 4:05pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188 "2020-05-04T16:05:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kktua123](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@kktua123](https://phaser.discourse.group/u/kktua123)\
**Post date:** [May 4, 2020, 4:05pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/1 "2020-05-04T16:05:40Z")

</div>

I just get this error when i touch the ‘lava’, i want the scene to restart/play a game over sreen, however, i can’t, it just gives me this error, i don’t understand why, while i use `this.scene.start('leveltwo);` and it works… i also tried to do `var scene;` and `var this;` but no one of this two works… any help, please?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [May 4, 2020, 4:32pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/2 "2020-05-04T16:32:28Z")

</div>

Show code please?

[https://github.com/samme/phaser3-faq/wiki#how-do-i-use-this-in-a-scene](https://github.com/samme/phaser3-faq/wiki#how-do-i-use-this-in-a-scene)

---

<div class="post-metadata">

**Author:** ![daveo](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/daveo/32/3184_2.png) [@daveo](https://phaser.discourse.group/u/daveo)\
**Post date:** [May 5, 2020, 2:41am UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/3 "2020-05-05T02:41:59Z")

</div>

```javascript
blankSquare.setInteractive();
blankSquare.on('pointerdown', self.handleClick);

```

‘this’ will be the ‘blankSquare’ object. so you could use:

```javascript
handleClick(event) {
		let offset = this.myKey;
		let owner = this.scene;

```

Here is my [Tic Tac Toe example](https://davidodonnel.com/2020/04/18/tic-tac-toe-playable-game/) that (hopefully) helps you figure out your issue 🙂

---

<div class="post-metadata">

**Author:** ![kktua123](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@kktua123](https://phaser.discourse.group/u/kktua123)\
**Post date:** [May 7, 2020, 12:10pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/4 "2020-05-07T12:10:30Z")

</div>

```
lava = this.physics.add.staticGroup();

            this.physics.add.collider(player, lava, hitlava);   

            lava.create(500,900, 'lava').setScale(5).refreshBody();

            function hitlava (player, lava) {

               this.scene.start('escenea');

                        }

```

I now how to start scenes, etc, the ‘escenea’ is defined and its the level two, but when the player touch the lava, i can’t restart or start a new one…

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [May 7, 2020, 3:20pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/5 "2020-05-07T15:20:12Z")

</div>

Hi @kktua123 ,  
The callback of your collider, `hitlava`, hasn’t the context of the scene, so `this` refers to the function that contains it (`hitlava`).  
A possible solution is access the scene from the sprite object:

```javascript
    function hitlava (player, lava) {

               player.scene.scene.start('escenea');

                        }

```

Regards.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [May 7, 2020, 3:44pm UTC](https://phaser.discourse.group/t/this-scene-is-undefined/6188/6 "2020-05-07T15:44:07Z")

</div>

> [@samme](#):
>
> [https://github.com/samme/phaser3-faq/wiki#how-do-i-use-this-in-a-scene](https://github.com/samme/phaser3-faq/wiki#how-do-i-use-this-in-a-scene)

> If you pass a callback that uses `this`, **you must also pass a callback context**. Pass `this` if you want to keep the scene context.
