Nullreferenceexception object reference not set to an instance of an object c# (94734)

So i am making a stealth game where i can hide in the shadows, i gave my point light a trigger and if i am in it it will debug the console. Now i want my ai to look at me if i am lit(I will add a field of view later). but i get null reference exception object reference not set to an instance of an object

here is my code Light Script:

using UnityEngine;
using System.Collections;

public class LightScript : MonoBehaviour {

	public bool lighted = false;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter (Collider other){
		if (other.gameObject.tag == "Player") {
			(lighted) = true;
			Debug.Log("lit");
		}
	}
	
	void OnTriggerExit (Collider other){
		if (other.gameObject.tag == "Player") {
			(lighted) = false;
			Debug.Log("unlit");
		}
	}
}

And here is my EnemyAI:

using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed = 1;
	public bool detection;

	private Transform myTransform;

	public LightScript detect = new LightScript();

	void Awake(){
		myTransform = transform;
	}

	// Use this for initialization
	void Start () {

			GameObject go = GameObject.FindGameObjectWithTag("Player");
				
			detection = detect.lighted;
			
			target = go.transform;
	}
	
	// Update is called once per frame
	void Update () {
			Debug.DrawLine(target.transform.position, myTransform.position);
			
			//Look At target
			if(detect == true){
				
			myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
		}
	}
}

First thing is: i wouldnt do GameObject go = GameObject.FindGameObjectWithTag(“Player”); this call has an impact on fps, especially if there are lots in the game.

i think putting a gameobject vaiable inside the enemy script and drag the player into it via editor

public GameObject player;

transform.LookAt(player.transform.position);

something like that… please check syntax

I found the answer

LightScript:

using UnityEngine;
using System.Collections;

public class LightScript : MonoBehaviour {
	
	public bool lighted = false;
	

	void Awake(){

		lighted = false;
	
	}

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
		
	}
	
	void OnTriggerEnter (Collider other){
		if (other.gameObject.tag == "Player") {
			lighted = true;
			Debug.Log("lit");
		}
	}
	
	void OnTriggerExit (Collider other){
		if (other.gameObject.tag == "Player") {
			lighted = false;
			Debug.Log("unlit");
		}
	}
}

And the EnemyAI:

using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed = 1;
	public bool detection;

	private Transform myTransform;
	
	public LightScript detect;

	void Awake(){
		myTransform = transform;
	}
	
	// Use this for initialization
	void Start () {

		GameObject go = GameObject.FindGameObjectWithTag("Player");
		
		target = go.transform;
	}
	
	// Update is called once per frame
	void Update () {
		Debug.DrawLine(target.transform.position, myTransform.position);
		
		//Look At target
		if (GameObject.Find("light trigger").GetComponent<LightScript>().lighted){

			myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
		}
	}
}