Start menu is dissapearing instantly

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class StartGame : MonoBehaviour
{
    private void Start()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}

Ive been working on my game for about a 3 months now and im close to finishing it and i just added my start menu but every time i hit play it disappears and goes to level 1 instantly this i s really frustrating what can i do too fix it.

Start will run as soon as the scene starts. In your code you load the scene straightaway so it will load the +1 index scene when you run it. That’s if Start is index 0.

If your start menu scene has buttons in you’d need to call your SceneManager code within a public method on a chosen gameobject.

I can also suggest to go into Build Settings and make sure the StartMenuScene is at index 0. You can drag the scene order by holding left mouse.

The docs say Unity builds scenes in the order in which they appear in the list.
Also make sure they have the tick box active on the left hand side to include them. You can add the start scene by clicking “add open scene” in the build settings with your start menu loaded up.

Ok thank you for your help, but i knew that my scene was supposed to be at start index 0 and I just made it a public method but for some reason nothing works I just dont understand why it does this.

I tried learning Timeline and Cinemachine. I created an activation track for a particle effect and it doesn’t work. I’m scratching my head too!

Never mind i Just found out why it wasnt working I used public void start which instanty started my game so i changed it too public void play game