Make retry button?


#1

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

`


#2

Check your typos in this function.


#3

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


#4

Yep been doing it on my own lol