Scene lock/unlock

Hello guys!

So after one month of working I almost finished my very first game, im working at the menu and the butttons of the game and its kinda rough because there are not so many tutorials where you can see different problems.Let me explain to you how the game works before asking the question itself, so basically my game is a jump game where you collect coins and must survive long enough, there’s a timer that when it gets 2500/2500 for example it takes you to another scene where you get more coins and so on.Every scene has other 3 scenes included but i want them to be locked and purchaseable with in game coins, my question is, how do i lock these 3 scenes so they can buy them and how do i make the timer change the scene only if the next scene is unlocked. i hope i made myself clear, i really didnt know how to ask this . Thx a lot

The information about locked scenes must be shared between scenes, so you’ll need global variables, but not sure what do you mean with “every scene has other 3 scenes included”. Please explain further this scenes system, so we can think the best way to store the locked state in the variables

So like, for example i start on scene 1 and if i survive until the timer gets to 2500 it takes me to scene 2, so like, another scene but i want them to be connected. so you cannot start on scene 2 without completing scene1 first.

Is the game linear though, so people can go to level 2 only if they have enough coin at the end of level 1 and then go to level 3 if they have enough coin at the end of level 2 or people can buy/unlock any level and start any level they have already unlocked in any order?

In case it is linear, it is simple.

If timer = 2500 and coin > 10 then go to next scene
if timer = 2500 and coin < 10 then restart current scene?
if player end level and coin > 10 then go to next scene
if player end level and coin < 10 then restart current scene?

Something like this.

In case the player is free to start any of the levels unlocked with coins, as Lizard-13 mentioned you need to store in a global variable the state of each level.

Level1State = “unlocked”
Level2State = “Locked”

If timer = 2500 go to level select
If player click level 2 and coin > 10 then Level2Sate = “Unlocked”
If Level2State = “Unlocked” go to Level2

Something like this…