Problem add componant : a script not found

Hi everyone,
I have an issue, sometimes when i make a script and when i want too attach it to a node, it’s not appearing in add component. Here is a picture. The script Hero is there but not in had component.
Anyone for help please ?

here is the code of my script hero, apparently 5errors but don’t know where…

`cc.Class({
extends: cc.Component,

properties: {
    jumpSpeed: cc.v2({x:0, y:300}),
    maxJumpDistance: 150,
    jumpSprite: {
        default: null,
        type: cc.SpriteFrame
    }
},

onLoad () {
    this.animation = this.node.getComponent(cc.Animation);
    this.sprite = this.node.getComponent(cc.sprite);

    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, event =>{
        switch(event.keyCode){
            case cc.macro.KEY.space:
                this.jumpKeyPressed = true;
                break;
        };
    });
    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, event => {
        switch(event.keyCode){
            case cc.macro.KEY.space:
                this.jumpKeyPressed = false;
                this.isJumping = false;
                break;
        };
    });

    this.node.parent.on(cc.Node.EventType.TOUCH_START, () =>{
        this.jumpKeyPressed = true;
        this.jumpKeyPressed = true;
    });

    this.node.parent.on(cc.Node.EventType.TOUCH_END, () =>{
        this.jumpKeyPressed = false;
        this.isJumping = false;
    });
},

start () {
    this.body = this.getComponent(cc.RigidBody);
    this.isJumping = false;
    this.jumpKeyPressed = false;
    this.touching = false;
    this.startJumpY = false;
},

onBeginContact(){
    // cc.log('onBeginContact'); 
    this.touching = true;
},

onEndContact(){
    // cc.log('onEndContact');
    this.touching = false;
},

onCollisionEnter(other, self){
    if(other.node.name === 'diamond'){
        other.node.destroy();
        this.node.emit('score');
    }
},

animate(){
    if(this.touching){
        if (!this.animation.getAnimationState('running').isPlaying){
            this.animation.start('running');
        }
    }else{
        if (this.animation.getAnimationState('running').isPlaying){
            this.animation.stop();
            this.sprite.spriteFrame = this.jumpSprite;
    }
},
update(dt) {
    if(this.jumpKeyPressed){
        this.jump();
    }
    this.animate();
},



jump(){
    if(this.touching){
        this.startJumpY = this.node.y;
        this.jumpFinished = false;
        this.isJumping = true;
        this.body.linearVelocity = this.jumpSpeed;
    }
    else if (this.isJumping && !this.jumpFinished){
        const jumpDistance = this.node.y - this.startJumpY;

        if(jumpDistance<this.maxJumpDistance){
            this.body.linearVelocity = this.jumpSpeed;
        }else{
            this.jumpFinished = true;
        }
    }
},

});
`

I think bracket was missing, here is corrected code:

cc.Class({
extends: cc.Component,

properties: {
    jumpSpeed: cc.v2({x:0, y:300}),
    maxJumpDistance: 150,
    jumpSprite: {
        default: null,
        type: cc.SpriteFrame
    }
},

onLoad () {
    this.animation = this.node.getComponent(cc.Animation);
    this.sprite = this.node.getComponent(cc.sprite);

    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, event =>{
        switch(event.keyCode){
            case cc.macro.KEY.space:
                this.jumpKeyPressed = true;
                break;
        };
    });
    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, event => {
        switch(event.keyCode){
            case cc.macro.KEY.space:
                this.jumpKeyPressed = false;
                this.isJumping = false;
                break;
        };
    });

    this.node.parent.on(cc.Node.EventType.TOUCH_START, () =>{
        this.jumpKeyPressed = true;
        this.jumpKeyPressed = true;
    });

    this.node.parent.on(cc.Node.EventType.TOUCH_END, () =>{
        this.jumpKeyPressed = false;
        this.isJumping = false;
    });
},

start () {
    this.body = this.getComponent(cc.RigidBody);
    this.isJumping = false;
    this.jumpKeyPressed = false;
    this.touching = false;
    this.startJumpY = false;
},

onBeginContact(){
    // cc.log('onBeginContact'); 
    this.touching = true;
},

onEndContact(){
    // cc.log('onEndContact');
    this.touching = false;
},

onCollisionEnter(other, self){
    if(other.node.name === 'diamond'){
        other.node.destroy();
        this.node.emit('score');
    }
},

animate(){
    if(this.touching){
        if (!this.animation.getAnimationState('running').isPlaying){
            this.animation.start('running');
        }
    }else{
        if (this.animation.getAnimationState('running').isPlaying){
            this.animation.stop();
            this.sprite.spriteFrame = this.jumpSprite;
        }
    }
},
update(dt) {
    if(this.jumpKeyPressed){
        this.jump();
    }
    this.animate();
},

jump(){
    if(this.touching){
        this.startJumpY = this.node.y;
        this.jumpFinished = false;
        this.isJumping = true;
        this.body.linearVelocity = this.jumpSpeed;
    }
    else if (this.isJumping && !this.jumpFinished){
        const jumpDistance = this.node.y - this.startJumpY;

        if(jumpDistance<this.maxJumpDistance){
            this.body.linearVelocity = this.jumpSpeed;
        }else{
            this.jumpFinished = true;
        }
    }
},

});

Indeed!! Thanks a lot :slight_smile: