[SOLVED] How to check if one component or a script is attached on one entity?

hi, I’m beginning on this playcanvas tour and it’s going good so far,

but i think it’s not possible for me to get this answer from the tut and API so I post here to ask.

i just wanna check one of my child entity has a (certain) script, or generally, has a component.

ive tried something like if(this.xxx.script.scriptName) , but it says the “scriptName” is undefined.

thanks anyway!

If it’s undefined, then it doesn’t have that script component.

Can you post a project link to give us some context to what you are trying to do please?

        console.log("this entity doesn't have modelManager.js !!");

it works will if currentMODEL entity has a script on it, but if it doesn’t, i got error message instead of reporting the content in ELSE section.

I changed it to


so it works now, and I just understood the game engine is checking “do we have script component” before checking “do we have a script called modelManager.js”, that’s why I got the error