checking Bool true from another Script?

I’ve looked around and cant work out why this script isn’t working for me looks just like all the suggestions that people give others? so I want to check if the bool is true on another script and if it is then I can take damage. this is what I ended up with any help would be great. :smiley:

Script 1 - BulletScript (placed on my bullet prefab)

public bool armed = false;

void OnCollisionEnter (Collision col)

{
if (col.transform.tag == “Shield”)

{
armed = true;

  print ("armed " );

}

Script 2 - Health System (placed on my enemy prefab)

void OnCollisionEnter (Collision col)

{
if (GameObject.Find(“PlasmaOrb”).GetComponent().armed == true && col.gameObject.tag == “Bullet”)

{

GoobaHealth -= damage; }

}

This is not clear at all

Either make a static script where you store variables, use getcomponent or add a reference to the script!

in script 2

add

public BulletScript bulletScript ;

to where you declare things in script2/health script.

everything in BulletScript needs to be declared as public so you can access them from another script.
make sure to drag the bullet script onto script2.

now you can access everything by calling for it

bulletScript.armed = false;

if(bulletScript .armed){
}

tbh if i were you i’d use

& use GetComponent

everything in BulletScript needs to be declared as public so you can access them from another script

when you hit it

so something like

void OnCollisionEnter(Collision collision)	{
		if (collision.gameObject.GetComponent<BulletScript> ()){
			if (collision.gameObject.GetComponent<BulletScript> ().Armed == true) {
			// do logic
			}
		}
	}

or

 void OnCollisionEnter(Collision collision)
    	{
    		BulletScript bulletScript  = collision.gameObject.GetComponent<BulletScript> ;
    		if(bulletScript){
    			if (bulletScript.Armed == true) {
    			// do logic
    			}
    		}
    	}

Here is some stuff to read/watch about statics too, might be handy in the future.