Javascript Syntax Errors

hey, sorry for the bad programming, but I need some help fixing the syntax errors here:

#pragma strict

var map : GameObject;
var onSound : AudioClip;
var offSound : AudioClip;
var canView : Boolean = false;
var viewing : Boolean = false;

function start ()
{
	map.GetComponent(MeshRenderer).enabled = false;
	canView = false;
	viewing = false;
}

function OnTriggerCollider (Col : Collider)
{
	if (Col.tag == "Player" && Input.GetKeyDown("e"))
	{
		canView = true;
		audio.PlayOneShot(onSound);
		destroy(gameObject);

	}
}

function Update ()
{
	if (canView = true && Input.GetKeyDown("e"))
	{
		audio.PlayOneShot(onSound);
		map.GetComponet(MeshRenderer).enabled = true;
		viewing = true;
		
	}
	
	if (viewing = true && Input.GetKeyDown("e"))
	{
		audio.PlayOneShot(offSound);
		map.GetComponent(MeshRenderer).enabled = false;
		viewing = false;
	}
}

here are some errors I got when I compiled my script:

Assets/My stuff/My scripts/ViewMap.js(29,21): BCE0044: expecting ), found ‘=’.

Assets/My stuff/My scripts/ViewMap.js(29,52): BCE0043: Unexpected token: ).

Assets/My stuff/My scripts/ViewMap.js(37,21): BCE0044: expecting ), found ‘=’.

Assets/My stuff/My scripts/ViewMap.js(37,52): BCE0043: Unexpected token: ).

sorry for knowing so little about scripting, I’ll try to improve :slight_smile:

Change:

if (canView = true && Input.GetKeyDown(“e”))

to

if (canView == true && Input.GetKeyDown("e"))

and

if (viewing = true && Input.GetKeyDown(“e”))

to

if (viewing == true && Input.GetKeyDown("e"))

Reason: You are currently using assignment operator (=) and you need to be checking for equivalence (==)

Looks like you are confusing the assignment operator =
and the equality test operator ==

The if statements require an equality test operator.