Opacity element function not recognized

Hello! I used a script and used this.entity.element.opacity = 0; function on a text element and it worked perfectly fine, but a few seconds after an error comes up and says function not recognized even though it works. Since I really want to publish this, I really don’t want any error messages popping up when it published. Many Thanks!

What exact error are you getting? And what is the code that it reports as the problem?

Thank you for replying! This is what pops up:

[Title.js?id=147441055&branchId=dc30da19-fd99-4ab0-8915-d98c8a4ece4d:13]: Uncaught TypeError: Cannot set properties of undefined (setting ‘opacity’)

TypeError: Cannot set properties of undefined (setting ‘opacity’)
at scriptType. (https://launch.playcanvas.com/api/assets/files/scripts/Title.js?id=147441055&branchId=dc30da19-fd99-4ab0-8915-d98c8a4ece4d:13:39)

That means that whatever you call . opacity on is undefined. Which means no object (material) was assigned to it.

oooh I understand now. I changed scenes right after the script i was using opacity for, so the new scene does not have any objects assigned to it while the script is still running. Do you think there’s anyway to fix this? Thank you.

like is there a way to stop the script before it changes scenes? Many thanks.

you can disable it

It works now!!! Thank you so much!!!