How to reference a GameObjects Box Collider true in a if statement!

I can not seem to find a way to check if that is the correct game objects box collider.

What I want to happen is when my “Player” enters a box collider [That is a Trigger] that has this script component attached to it, I want it to double check that it is indeed the player, then searched for the right box collider.

I made a reference to the game object then enabled it on awake, and then in the if statement I wanted it to make sure it was that box collider

Thank You for your Help

–Not posting full script here as it would take up unnecessary room----

private bool playerCollCheck = false;

//GameObject
private GameObject battery; // Referance to the GameObject with the BoxCollider on it
private GameObject safeRoomKey; 

//Collider
private BoxCollider safeRoomboxCollider;
private BoxCollider batteryboxCollider;

void Awake()
{

    battery = GameObject.Find("BatteryController"); // Find the gameObject with the BoxCollider
    safeRoomKey = GameObject.Find("SafeRoomKeyController");
}

void OnTriggerStay(Collider coll)
{
    if (GameObject.Find("Player").GetComponent<myCharacterController>().itemTaken)
    {
        PlayerCheck(coll);
        if (playerCollCheck == true)
        {
            mainKeyTextController();
            batteryTextController();
        }
    }
}

void mainKeyTextController()
{
    if (safeRoomKey.GetComponent<BoxCollider>())
    {
    Debug.Log("Picked up Safe Room Key");

    }
}

void batteryTextController()
{
    if (battery.GetComponent<BoxCollider>())
    {
     Debug.Log("Picked up a Battery");
    }
}

void OnTriggerEnter(Collider col)
{
if (col.GetComponent())
{
//have this script
}

else
{
//dosent have it
}
}

So in short you have a player and a number of objects with a scrip. When the player collides with any object, you want to print out its name.

The thing you are missing here is that this script is attached to all the objects (as you said) and the script “knows what object it is attached to”. When you collide with the objects, each object (that collides) runs its own OnTriggerEnter. That method doesn’t need to check all other objects, just itself. Something like

private GameObject player;
 void Awake()
 {
     player = GameObject.Find("Player");
 }
void OnTriggerEnter(Collider coll)
 {
// something collided with the object that
//this script is attached to
     if (coll.gameObject == player)
     {
// it was the player this object collided with
         Debug.Log("Picked up " + name);
// print the name of this object
     }
}

Also, the basic mistake in your if-checks is that you are not comparing what is colliding with what.

//this just checks whether battery has a BoxCollider
if (battery.GetComponent<BoxCollider>())

In order to know if it’s the right collider, you must compare it with something

void OnTriggerEnter(Collider coll)
{
    if (coll == battery.GetComponent<BoxCollider>())