Resetting an entity

Ok so I’m trying to make it so when you click a key the level resets,but the code isnt working
here’s the code:

var Al = pc.createScript('Al');

//variables and scripts//
var menu = Score;
var Score = dlevel;
var dlevel = this.entity;
var reset = 'null';

Al.prototype.intalize = function() {
   if( {


Al.prototype.reset = function() {

Your code seems to have several issues:

  1. this.dlevel which should be just dlevel (local variable) is already a pc.Entity alas you try to access an entity property on line 11. That wouldn’t work unless you added a custom entity property on your entity manually.

  2. You try to access the reset method as a property method on your entity. That wouldn’t work either, that method should be accessed on the the script context:

  1. Then on your reset method you try and call the findByName method with wrong arguments. Try reading the documentation on the pc.Entity class to learn how to do that: