[SOLVED] Uncaught TypeError: Cannot read property 'play' of undefined

this error happens when i try to play sound through a script on a collision trigger. can somebody help?

It means whatever object you are trying to use .play on is null or undefined. Post the code if you need more precise advice.

i do need that


// initialize code called once per entity
Trigger.prototype.initialize = function() {
    this.entity.collision.on('triggerenter', this.onTriggerEnter, this);
};

Trigger.prototype.onTriggerEnter = function(entity) {    
     this.entity.sound.play("wpn_portal_fizzler_shimmy_01");
        this.entity.sound.play("portal_fizzle_01");
};

So there is no sound component on this.entity. Trying opening Chrome Dev Tools (or whatever browser you’re using) and setting a breakpoint on the first line with sound.play. Then inspect this.entity to check it’s the entity you expect. And check in the Editor that that entity does actually have a sound component.

so i fixed that, but now i have this: 55

the files are in there by the way02

nevermind i figured out that it was asking for the name of a sound that was set to it