Pausemenu script problem

Can someone please fix the errors in this code

#pragma strict

var GamePaused : boolean = false;

function Start () {;

};

function Update () {

if (Input.GetKeyDown (KeyCode.Escape)
  )if (GamePaused){;
  Time.timeScale=1;
  var gamePaused = false;
 var gameObjectGetComponent;PauseMenu .enabled = false; 
}
else (
Time.timeScale )= 0;
gamePaused = true;
gameObject.GetComponent;(PauseMenu).enabled = true;
}

what errors are you getting?

The error I get is 'Unknown Identifier:‘PauseMenu’ for BCEOOO5 and for BCEOO34 the error is 'Expressions in statements must only be executed for their side-effects.

ah, you set “GamePaused” as a script variable at the top… then on line 14 you set a local variable within that if statement of “gamePaused” then in the else statement you try to access “gamePaused” which doesn’t exist within that scope.

In unity the case of the letters matter, so gamePaused and GamePaused are different things.

It also looks like you’ve missed a bit when looking at the scripting reference page for GetComponent… both usages don’t actually do anything since they don’t assign what is returned to a var and neither pass the required parameter of “type” so i’d expect them to error too. Might want to revisit those reference pages.

I’d also very much recommend that you try to layout your code in a more consistent manner, it’s far easier to read and spot mistakes if it looks something like:

function Update () {

if (<condition a>)
	{
		if (<condition b>)
		{
			<do stuff>
		}
		else
		{
			<do something else>
		}
	}
}

Thanks LeftyRighty, I wondered why the guy in the tutorial I copied fro did ‘gamepaused’ instead of ‘GamePaused’.

gameObject.GetComponent**;**(PauseMenu).enabled = true;

Pretty sure this line ender isn’t helping