Level Gateway is not working

I would like some help concerning my gateway function. Basically, I want my character to gain 10 coins and go to this mailbox to go to the next level. I got the 10 coins now, but the mailbox is not working. I tried to use collision to trigger it but it is not working. I am relatively new to this software so I would like some help.

Hi @RafaGarcia and welcome! Can you share the editor link of your project so someone can take a look?

Here you go

As far I have seen, your mailboxNextLevel.js script is not correct. Please check the page below to see how the functions should look like.


I see. But I don’t understand the function exactly, I am still quite new to coding in general and I’m doing this for school. My other classmates have something different than what I see from the developer page which is odd but it does work. May I ask how the script is wrong? I’m sorry because I am still quite new…

I was working on my team’s game and we made some progress, however, we stumbled upon this problem.

I tried looking for the error but I’m fearful that if we change anything from the script, the function would not be working the same.

Can anyone help?

On line 13 you close the function, but you should do this after line 19.

Thank you very much! It worked! But if I may ask, how come closing the function on line 13 caused an error despite the system not detecting it?

The code is detected, but no longer read correctly because the code is not placed in the correct context. So in this case, you use result which is defined in your function. Outside the function the system doesn’t know what you mean with result and that gives the error.

By the way, changing the scene is easier these days. Below is all you need.

this.app.scenes.changeScene("Scene Name");
1 Like