Make retry button?

Ok so I did the button does restart the gaame whenyou press it.But I also wanna make it so when you press a key such as h it resets automatically.
Heres the script I coded and tried

var R = pc.createScript('r');

R.attributes.add("pointA", {type:'entity',title:'APoint'});
R.attributes.add("ball", {type:'entity',title:'Ball'});

var element = this.retryButton;

//hopefully resets when button is pressed
R.attributes.add('btnElement',{type:'entity'});

R.prototype.intalize = function(dt) {
    this.entity.findByName('retry');
    this.entity.element.om('retryBtn', this.entity.reset);
};

R.prototype.update = function(reset) {
  if(this.app.keyboard.wasPressed(pc.KEY_H)) {
      this.reset();
  }
};

R.prototype.reset = function() {
    this.ball.retryButton.teleport(this.pointA());

};

R.prototype.onClick = function(e) {
    this.dlevel.enabled = true;
    this.level.enabled = false;
    
};

But theres something wrong with the script it says this

`

1 Like

Check your typos in this function.

1 Like

Other than a few bugs, the game is looking great!

Yep been doing it on my own lol