How to clear ALL scripts from an entity in code?


is fine if you know the name of the script. But what If I need to just remove every single script from an entity no matter what its called. How do I do that?


Hi @Grimmy,

There is a scripts property under the .script component:

Though I’m not sure how to grab the script type name from there. Internally the engine does something like this using private API:

// destroy all scripts
for (let i = 0; i < this.entity.script.scripts.length; i++) {
   const script = this.entity.script.scripts[i];
   if (!script) continue;


I think you could instead remove the script component altogether and re-create it: