The left-hand side of an assignment must be a variable, a property or an indexer

Hello, I’m making a AI system, but when I want to take a boolean from another script, it gives me eror: The left-hand side of an assignment must be a variable, a property or an indexer i dont know, what to do…

This is the sript, where i’m using the taken boolean:

using UnityEngine;
using System.Collections;

public class AI : MonoBehaviour {
	public Transform target;
	public float speed = 5.0f;
	void Update ()
	{

		if (GetComponent<seen> ().Seen) {
			transform.position = Vector3.MoveTowards(transform.position, target.position, speed*Time.deltaTime);
		}
	}
}

And this is the script, I’m taking the boolean called seen:

using UnityEngine;
using System.Collections;

public class seen : MonoBehaviour {

	public bool Seen;
	
	void OnCollisionStay2D (Collision2D coll)
	{
		if (coll.gameObject.tag == "Player") {
			seen = true; //Editor says the error is here
		}
	}
}

If you get it, I’d be verry happy :smiley:

The problem is on line 11. You are trying to see ‘seen’ with a lower case ‘s’ to true (which is the class) instead of ‘Seen’ with an upper case ‘s’. Change the line to:

 Seen = true;

Note about naming. By convention, variables start with a lower case letter. Classes and functions/methods start with an upper case letter.

Also for future posts, please include a copy of he error message from the console. It gives us the file and line number of the error as well as the stack trace.