Problem with unchanged script in .getLocalScale

Hi i am having a problem with my script that i havent touched since yesterday and was working fine is now showing an error on getLocalScale saying it is undefined can anyone seem to know why its calling the error?

var Health = pc.createScript('health');

// initialize code called once per entity
Health.prototype.initialize = function() {
this.camera = this.app.root.findByName('Camera');
this.textElement = this.entity.findByName('nHealth');
this.weaponEntity = this.entity.findByName('sword');
this.healthEntity = this.entity.findByName('eHealth'); // we're searching inside the entity
//var scale = new pc.Vec3().copy(this.healthEntity.getLocalScale()); // store the scale inside a new vec3 (scale is a vec3)
//var rotate = new pc.Vec3().copy(this.weaponEntity.getRotation());
    this.takeDamage = 0;
};

// update code called every frame
Health.prototype.update = function(dt) {
  //  this.entity.setRotation(this.camera.getRotation());
    var scale = new pc.Vec3().copy(this.healthEntity.getLocalScale()); // store the scale inside a new vec3 (scale is a vec3)
    
if (this.app.mouse.isPressed(pc.MOUSEBUTTON_LEFT)) {
    scale.x = pc.math.lerp(scale.x, 0, 0.5);  // SCALE DOWN
} else {
    scale.x = pc.math.lerp(scale.x, 1, 0.001);  // SCALE UP
}
this.healthEntity.setLocalScale(scale);
    if (scale.x < 0.01) {
        scale.x = 0;
        this.entity.script.dead.dead = true;
    }
    if (scale.x > 1) {
        scale.x = 1;
    }
    if (this.takeDamage > 0) {
        scale.x -= this.takeDamage;
        this.takeDamage = 0;
    }
    this.healthEntity.setLocalScale(scale);
};
Health.prototype.destroy = function() {
  if (this.app.root.Enemy(isDead)) {
      
  }  
};

Even if the code hasn’t changed, the data and the scene might have so look for your dependencies that this code uses. What is this code reliant on? What could have changed to cause this error?

What object is getLocalScale() called on?

Sorry i thought i edited [SOLVED] in but i figured it out i had it calling on two things on accident but i got it working again now thanks though :slight_smile: