Scenes not loading in the correct order

Hi, I’m currently creating a basic unity 3D game and I have come across a problem with the scenes not loading in the correct order.

I have a main menu , 3 levels, a ‘You win’ and finally a ‘You lose’ scene (making a total of 6 scenes in that build order.)

However after clicking new game, it enters level one, upon completing level 1 it repeats level 1, then upon completing level 1 again it will successfully load level 2, and then upon completing level 2 it jumps straight to the ‘You win’ scene.
I am new to unity and coding in general and feel i am missing something relatively obvious but i have been looking for hours for a solution and found nothing. Any help would be appreciated!

Here is the GameManager part involved:

using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class GameManager2 : MonoBehaviour{

public int currentScore;
public int highscore;
public static int currentLevel = 0;

void Update()

{  
    startTime -= Time.deltaTime;
    currentTime = string.Format("{0:0.0}", startTime);
    if (startTime <= 0)
    {
        startTime = 0;
        SceneManager.LoadScene(5);
    }
}


public void CompleteLevel()
{
    if (currentLevel < 4)
    {  
        //this loads levels in sequence
        SceneManager.LoadScene(currentLevel += 1);

    
    }
    else {

        //this is the win settings
        SceneManager.LoadScene(4);
        print("You win");
    }
} 

Here is the MainMenu part involved:

public void LoadScene(string name)

{

    SceneManager.LoadScene(name); 

}

public void QuitGame() { 

    Application.Quit();
}

}

I was worried i had put them in the wrong order in the build settings so I removed all levels and placed them all back in in the correct order but that didn’t help. As far as i can tell they are definitely in the correct order (but as i said i am new to unity).

thanks for reading and any help would be greatly appreciated :slight_smile:

FIXED!

finally found a fix in the end!

needed to use:

if (currentLevel < 4) { currentLevel = SceneManager.GetActiveScene().buildIndex+1; SceneManager.LoadScene(currentLevel); }