error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Hi! I pretty new to c# , i trying to make a script to “teleport” the player to another “scene” when it enter a collider,also with a little gui asking him if he want to enter the scene, just press “f”,finally removing the little gui when it exit the trigger,but i got this error

TeleporterC.cs(46,41):error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Line 46 is the last function OnTriggerExit,with the drawGui variable…

using UnityEngine;
using System.Collections;

public class TeleporterC : MonoBehaviour {
	
	public string teleportToMap = "Level1";
	public string spawnPointName = "PlayerSpawn1"; //Use for Move Player to the SpawnPoint Position
	public string toText = ""; //What you want the target location to say on-screen

	private bool drawGui = false; //Control for the GUI group layout

	void Update(){

		if(drawGui == true && Input.GetKeyDown(KeyCode.F)){
			ChangeMap();
		}
	}

	void OnTriggerEnter(Collider other){

		if(other.tag == "Player"){
			other.GetComponent<StatusC>().spawnPointName = spawnPointName;
			ChangeMap();
		}		
	}

	void ChangeMap(){

		Application.LoadLevel (teleportToMap);
	}

	void OnGui(){

		if(drawGui == true){
			GUI.skin.box.fontSize = 18;
			GUI.backgroundColor = Color(255,0,0,0);
			GUI.BeginGroup(Rect(Screen.width /2 - 75,Screen.height /2 - 0,200,75));
			GUI.Box(Rect(0,0,200,25),"Press F to Enter");
			GUI.Box(Rect(0,22,200,25),toText);
			GUI.EndGroup();
		}
	}

	void OnTriggerExit(Collider other){
		if(other.tag == "Player"){
			drawGui == false;
		}
	}  	
}

What cause me this error,anyone?

Thank you

you can’t

drawGui == false;

you must

drawGui = false;

:slight_smile:

always check for silly errors.

In my case I am Instantiating gameobject,but not assigned to a gameobject
means

Instantiate(...);

When I changed code to

GameObject object = Instantiate(...);

error goes away.May help some one with same problem.