How to use OnTriggerEnter on different gameobject to detect collision?

I have an empty GameObject called collider with collider2D with trigger on
I have an Sprite called Ball with rigidbody and Collider2d aswell
I also have empty gameobject called ColliderScript to my collider script.
My question is how to use tags to detect the collision between collider and Ball and print out something if my script being attach to collider script. I tried tags and nothing works, nothing printed out.

    void OnTriggerEnter2D(Collider2D col)
    {
        player2Collider = GameObject.FindGameObjectWithTag("Player2Collider");
        Debug.Log(" Worked");
    }

void OnTriggerEnter2D(Collider2D col)
{
if(col.gameObject.tag == “Ball”)
{
//add the code you want to execute on collision
//to access the Ball gameObject use : col.gameObject
}
}

attach this scipt to the collider GameObject and add the tag “Ball” to the Ball GameObject

what is code for unity 3d

im pretty sure in 3D its the same, but without the “2D” after some words.