[SOLVED] Cannot read properties of null (reading 'element') and Cannot read properties of null (reading 'url')

I’m hit with a double whammy on this one. I was checking my team’s project and found that our How to Play scene has two issues “cannot read url” and “cannot read element.”

I tried to change the placement of the braces “{}” but to no avail. Can someone help?

For the url

For the element

Hi @RafaGarcia!

It looks like you try to change the scene. Please check my post below.

If you still have problems, please share a link of your project.

Hello. Sorry for the late reply. I’m using the script you provided. It works, but the scene changes automatically instead of being initiated by a click. Can you help me with this?

Where did you add the code that I provided? Did you replace the other scene load scripts with it? Otherwise they are probably going to conflict with each other.

I made a new script specifically for the About Us screen. The other buttons for the main menu work except for the About Us button. So I made a new script for the button.

Here it is:
https://playcanvas.com/editor/code/1006419?tabs=111387025,111384490,111369395,113983205

Right now the code is executed as soon as the script is active. Probably at the start of your game. I guess you only want to execute it when you click on the button. Please check the page below to see how you can do that.

https://developer.playcanvas.com/en/tutorials/ui-elements-buttons/#button-events

Thank you very much. This is much simplier than what my school is teaching me tbh. Thank you very much for the help. :slight_smile:

1 Like

You’re welcome! The changeScene API is new, so maybe the school doesn’t know yet.

https://developer.playcanvas.com/api/pc.SceneRegistry.html#changeScene

That’s a possibility. Thank you very much for your help :slight_smile: