Duplicate Question http://answers.unity3d.com/questions/1229382/how-do-i-return-scene-using-bulid-index-scenemanag.html
How do I switch scenes in a else statement
I gotten the scene to switch in the if statement . I want my scene to switch in the else statment. When I code in else statement . I get errors. I get want to scene to switch with lesser points when timer which . I am doing the same thing in the if statement its just with lesser points else statement here is my code :
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class TestScript : MonoBehaviour
 {
     public MyClockScript myClock;
     public ScoreManagerScript scoremanager;
     
     public int scoreToReach = 99;     // change this value to what you want
     public int leastscore = 50;
     public string nextScene = "FY"; // change this value to what you want
 
     void Update () 
     {
           if (myClock.m_leftTime <= 0)
               {
               if ((ScoreManagerScript.score >= scoreToReach) && (nextScene != ""))
                      {
                      SceneManager.LoadScene(nextScene);
                      }
               else
                     {
                     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
                     }
                }
  
     }
     
 }   
     
 
 
              You have not initialized 'myClock' and 'scoremanager' yet you are using them. Trying initializing them on the Start/Awake methods before using them.
Follow this Question
Related Questions
How do I make scenes switch properly c# 0 Answers
garbage collection in between scene changes? 2 Answers
Restarted scene not working properly 0 Answers
Level Selection Menu...Preview Scene 1 Answer