Can't find variable error

Screen Shot 2023-03-31 at 9.12.29 PM

How do you define the variable? Here’s the code where i got “ScoreText” from

The cause is probably elsewhere. Can you post your project please?

https://playcanvas.com/editor/scene/1690805

I asked my prof and she said it’s probably just cause i didnt declare it (dont know how) or its a text element (not sure either)

Current code:

// initialize code called once per entity
CollisionScript.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);
    var scoreText = this.app.root.findByName("score");

    Scoretext.element.text = "ROOMS COMPLETED:" + scoreCount.toString();

};

Should be

// initialize code called once per entity
CollisionScript.prototype.initialize = function () {
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);
    var scoreText = this.app.root.findByName("score");
    scoreText.element.text = "ROOMS COMPLETED:" + scoreCount.toString();
};

Did you save your script file in the Code Editor? What I see doesn’t match what you posted in your first post.