[SOLVED] Cannot read property of script

After click new game, my player will clone in the middle of plane and controller will be enable at the right corner. In order to control the movement of player, I using this.app.root.findByTag method to get my player (my player has a tag call myPlayer). While console.log the player with tag, the array showing that it able to find my player. But when I trying to move the controller, I giving out that my Cannot read property ‘MyScriptName’ of undefined. What I should do to pass the controller value to the player movement value? The value that when I move the controller store in dragnwescript.js and the pass the value to playerMovement.js to move the player.

That my project link here PlayCanvas 3D HTML5 Game Engine

Hi @Elliot ,

The following method returns an array of all entities that have that tag:

// this is an array
var player = this.app.root.findByTag('myPlayer');

That means if you would like to access the first entity in the list do this:


Wow, that fix the problem.
Thanks for helping @Leonidas .

1 Like