How to differentiate objects with the same script?

I posted another question but I didnt really know what the issue was but I found a more detailed answer so I know what I need to fix but im not sure how to.

So basically, I have multiple tree objects, all with the same script that add one to a variable called woodAmount when you click, but when I click on one of the objects because the condition has been set to true the script runs on all the trees that have the script so how can I differentiate them so that they only run when they are clicked. I was hoping I wouldnt have to use tags or smth like that so what is the simplest but effective way to fix this issue?

Here is the script attached to the trees :

void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D rayHit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
            
            if (rayHit.collider != null)
            {
                Debug.Log("Target Position: " + rayHit.collider.gameObject.transform.position);
                GameObject.Find("GameManager").GetComponent<GameManagerGen>().TreeHit();
            }
        }
    }

You are checking raycasts for all of the trees then using your game manager to call TreeHit method. This is mostly unnecessary, instead you should check the raycasts from game manager and when it hits, you should call the TreeHit method, which is in tree script. Something like :

hit.transform.GetComponent()?.TreeHit;