TypeError: Cannot read properties of undefined (reading 'text')

I’m making a Phaser 3 Pong clone and i’m getting these errors on line 127 and 128.


:wave:

How are you calling updateScore()?

Seems like this is a callback function and is using the “this” context of wherever it is being called. There are lots of different ways to manage what “this” is referring to in javascript, but it looks the .add.text and .physics.pause functions probably belong to your scene, so it may be less confusing to include a reference to scene in the updateScore function parameters, and then call scene.add.text and scene.pysics.pause inside the function.

You’ve also don’t seem to be using the “game” argument in your updateScore function. If this is a reference to Phaser.Game, it’s probably not something you need or want to mess around with, scenes control pretty much everything in Phaser, so toss that in there instead.

I forgot I posted this, I solved my problem a few days ago!