How do I check a bool from another script??

Hi so I’ve been looking through forms all night… and haven’t found something that will work… In EnemyScript i am trying to see if a bool from PlayerScript is false:

EnemyScript:
using UnityEngine;
using System.Collections;

public class EnemyScript : MonoBehaviour
{
public PlayerScript checkDeath;

void Start ()
{
	GameObject g = GameObject.FindGameObjectWithTag ("Player");
	checkDeath = g.GetComponent<PlayerScript> ();
}
void OnMouseDown ()
{ 
	if (health <=0)
	//if the health is 0 or less.. 
	{
		if(checkDeath.Dead = false)
		//and if the object isn't active..
		{
			Destroy(gameObject); 
		}
	}
	 
}

I took out the unimportant stuff… but i’m trying to find out if the bool “Dead” from PlayerScript is false… and if it is then to destroy the object…

Im not sure what you need to see from PlayerScript other than the fact that there is a public bool on it… Please help!! thanks!!

From your code what I understand is your check condition is assigning the value instead of checking, you need to place “==” instead of “=” in ‘if’ condition.Try to replace the code

         if(checkDeath.Dead = false)
         //and if the object isn't active..
         {
             Destroy(gameObject); 
         }

To 

         if(checkDeath.Dead == false)  //  or can also use  if(!checkDeath.Dead)
         //and if the object isn't active..
         {
             Destroy(gameObject); 
         }

Or second problem you may facing is the Player is dead and he is not more present in the scene so the script is also get destroyed , but you are trying to access that but it is giving you the error.

Declare your dead bool type to any other script (Public Static bool Dead;) that script is not destroy like PlayerScriptis destroy when Player gameobject is destroyed…

and You can access that dead bool variable to playerScript or any script like(othertScrpt. Dead = true;)…