Change Scene by answering right

I’m making a guess the movie game, and I need to change to scene “level 1” when the person answers correctly. But now it only says that they answered correctly, Can anybody help my with making the C# script that makes it change scene when the player answers correctly? thanks in advance :slight_smile:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Spawn: MonoBehaviour {

private string gameName;

private int countGuess;

private InputField input;

private Text text;

void Awake(){
	gameName = "spawn";
	text.text = "Guess The Name Of The Game";
public void GetInput(string guess){
	input.text = "";
public void ChangeToScene (string sceneToChangeTo) {
public void CompareGuesses (string guess){
	if (guess == gameName) {
		text.text = "You Guessed Correctly";

	} else if (guess != gameName) {
		text.text = "Wrong!";
	} else if (guess != gameName) {
		text.text = "Wrong!";



firstly do you have the statement using UnityEngine.SceneManagement at the top?
otherwise, have you added the scene that it should switch to in the build settings?
Hope this helps.

Add the scene you want to load to the build settings : File → Build Settings… → Add Open Scenes.

In script, when the player answered correctly use :


And don’t forget to add :

using UnityEngine.SceneManagement;

at the beginning of your file.