Script removed from "scripts", but not from "order"

Hi!

During refactoring a project (replacing scripts with new versions with different names), some scripts left in “order”, but removed from “scripts”, so code “enabled: data.scripts[data.order[i]].enabled,” falls with error " [playcanvas-1.70.3.js:65245]: Cannot read properties of undefined (reading ‘enabled’)".

For some project fixed somehow after adding scripts again and rearranging and removing them, but for PlayCanvas | HTML5 Game Engine it doesn’t help. Maybe someone could fix that?

@Mark_Lundin - any idea about this?

Were you changing the execution order or loading order? I can’t replicate this on my side. If you could provide some steps to reproduce then I can take a look

All my scripts are in one js-file, so loading order doesn’t matter. The “scripts” and “order” I’m talking about are the properties of the script component of the entities from scenes.json when I export the project.

If you run PlayCanvas | HTML5 Game Engine, you could see the error message like that:

Thanks for this @alex.panoptik. Can you add MARK-SNAP to the project, and I can take a look?

Added.

For some reason the order for the CloseButton appears corrupt in your project. It’s tricky to debug as your scripts are all compiled into a webpack build, but you should be able to fix this by finding all entities with the CloseButton attached (mainly PrevButton) and removing the CloseButton script and then re-adding it again. Also on the ‘Avatar’ entity you seem to have 2 event provider scripts attached EventProvider and event-provider, you’ll need to remove the incorrect one.

Hope that helps

Thanks, it helped.