Very annoying error

Hey everyone! So I’m getting this very annoying error : Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.
I am looking all over my code and I cannot find it. Maybe someone know how to fix it or can find it.
Code:

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

public class Hacker : MonoBehaviour
{
    //Game config data
    string[] passwords1 = {"jail", "drug", "dealer", "people", "handcuffs"};
    string[] passwords2 = {"search", "database", "user", "computer", "key"};
    string[] passwords3 = {"spaceship", "weird", "extraordinary", "extraterrestrial", "secret"};
    //Game State
    int level;
    string password;
    enum Screen {MainMenu, Password, Win};
    Screen currentscreen;
    
    // Start is called before the first frame update
    
    void Start()
    {
        ShowMainMenu();
    }
        

    void ShowMainMenu()
    {
        currentscreen = Screen.MainMenu;
        Terminal.ClearScreen();
        Terminal.WriteLine("What whould you like to hack into? \n Press 1 for the police \n Press 2 for Google \n Press 3 for Area 51 \nEnter your selection:");
        
    }

    void OnUserInput(string input)
    {
        if (input == "menu")
        {
            ShowMainMenu();
        }
        else if (currentscreen == Screen.MainMenu)
        {
            RunMainMenu(input);
        }
        else if (currentscreen == Screen.Password)
        {
            CheckPassword(input);
        }
    }
    void RunMainMenu(string input)
    {
        bool isValidLevelNumber = (input == "1" || input == "2" || input == "3");
        if (isValidLevelNumber)
        {
            level = int.Parse(input);
            StartGame();
        }
        else if (input == "007") // easter egg
        {
            Terminal.WriteLine("Please select a level Mr.Bond");
        }
        else 
        {
            Terminal.WriteLine("Please choose a valid level");
        }
    }
    void StartGame()
    {
        currentscreen = Screen.Password;
        Terminal.ClearScreen;
        switch (level)
        {
            case 1:
                password = passwords1[0];
                break;
            case 2:
                password = passwords2[1];
                break;
            case 3:
                password = passwords3[2];
                break;
            default:
                Debug.LogError("Invalid level number");
                break;
        }
        Terminal.WriteLine("Please enter your password:");

    }

    void CheckPassword(string input)
    {
        if (input == password)
        {
            Terminal.WriteLine("Correct!");
        }
        else
        {
            Terminal.WriteLine("Wrong password, Try again");
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

Thank you in advance

Hi Sol7,

Double click on the error message. To which line in your code does it refer?

If you already solved the problem, please post your solution anyway and feel free to mark it as the solution. :slight_smile:


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms