The teleport script form the "roll a ball" project has an error

It says “annot read properties of undefined (reading ‘on’)”:

var Teleport = pc.createScript('teleport');

Teleport.attributes.add('target', {
    type: 'entity',
    title: 'Target Entity',
    description: 'The target entity where we are going to teleport'
});

// initialize code called once per entity
Teleport.prototype.initialize = function() {
    if (this.target) {
        // Subscribe to the triggerenter event of this entity's collision component.
        // This will be fired when a rigid body enters this collision volume.
       this.entity.collision.on('triggerenter', this.onTriggerEnter, this);
    }
};

Teleport.prototype.onTriggerEnter = function (otherEntity) {
    // it is not teleportable
    if (! otherEntity.script.teleportable)
        return;

    // teleport entity to the target entity
    otherEntity.script.teleportable.teleport(this.entity, this.target);
};

Can anyone help me? Here is my game: PlayCanvas 3D HTML5 Game Engine

This looks like it’s happening because you have the script applied to an entity that does not have a collision component.

I opened scene ‘R2 D2’ and you have applied teleport.js to Entity called Clilinder. This entity does not have a collision component. So this.entity.collision will return undefined (or maybe null).

OOOH thx

I fixed that but my character doesn’t teleport, and yes I have the teleportble script