Why does the Scene repeat or go back to level 1

I made a game and when I press play it goes to the level selection menu and when I click level 1 and finish it, it will pull up “next level”. When I click that, it goes back to level 1. But it fixes when I finish level 1 again it goes to level 2. Then when I click level 2 in the selection menu and finish level 2. It goes to level 1.

Here is some pictures that may help: (I was unable to put the other image so I put the image in a reply)
Image <------ This is an image as well

Here is a visual of this issue:
Screen recording 2023-02-05 1.29.02 PM.webm <----- Click to go to video

Here’s the last image
Screenshot 2023-02-04 4.13.22 PM

Is your GV(currentlevel) set at 0? So when you click, you add 1, so level 1 repeats. Then, next time it adds again, so level 2 shows correct.

Can you show me an example of this

I guess what I was asking was, did you declare the globalvariable(currentlevel) first? Or is it like this in the GlobalVAr properties?


Because unless you changed it in code to “1” before you completed level 1, I think what i happening is it is set at “0” (default), so when you complete level 1, it adds 1 to it, but that makes the globalVar(currentlevel) = 1 which is why it repeats level 1. When you complete level 1 again, it adds the next one, which is why level 2 works as intended. You may want to set the GlobalVariable(currentlevel) to 1 when you press the first “level 1” button, so that when the level is complete, it addds one as you have it, taking you to level 2 as you expect … hope that helps :slight_smile:

Ok, it worked :smiley:
Thanks for the help

Wait, there is another problem! When level 3 or 4 is clicked in the selection menu, it goes to level 2. I want it to go smoothly and actually work. Any solutions?

I am really planning on releasing this update because I think people are getting mad about this. I hate to have people putting bad reviews

So do they always have to click the level button to go to the next level? Why not just make a variable for each button for the level (like button.Variable(1) for level 1 and so forth), set the Global Variable to that button variable?

Lol, can you show an example. I am not visualizing this. Usually I would but I am just not. Thanks :slight_smile:

So it looks to me from your video you have two ways to advance a level: click the menu button, or hit next level on completing a level. When the player hits the menu button (ie, level 2), set the global var(currentlevel) to 2, so they start on level 2. When they complete level 2, keep your add one the global var(currentlevel) so they advance to the next level from there. But if they go back to menu and select another level, the global var(currentlevel) will be replaced when clicking that button (ie level 4 wold set it at 4) thereby advancing to level 4. With out actually seeing your code for the menu buttons, I am not sure what it is doing to advance, but each level button on the menu needs to be kind of hardwired to that level for that button … hope that makes more sense :slight_smile:

ok, it has worked i’m pretty sure

Ok, yes it worked. Thank you!!! :+1:

1 Like