== not working

Hi, I am not very experienced in Unity, and I am trying to create a game.
It is supposed to be such that if you type start in an input field and press enter, it brings you to the next scene.
However, when I type start into the input field and press enter, nothing happens.
If I change == to != and type start, it still goes to the next scene.

Here is my code:

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class StartMenu : MonoBehaviour {

private GameObject command;
private string Command;
private LevelManager levelManager;

// Use this for initialization
void Start () {
Command = command.GetComponent().text;
}

public void Enter(){
print(“Game Started”);
SceneManager.LoadScene(“Game”);
}

void Update () {

if (Input.GetKeyDown(KeyCode.Return)){
if (Command != “start”){
Enter();
}
}
}
}

Please help me.
Thanks in advance.

Please, use the proper tag when you post a script: Using code tags properly - Unity Engine - Unity Discussions

1 Like

You are setting the value of Command once when the game begins. You should be setting it directly before checking the value.

if (Input.GetKeyDown(KeyCode.Return)) {
    Command = command.GetComponent<InputField>().text;
    if(Command == "start") {

    }
}