Making Tree Invisible when Player is under it

I have a simple script attached to an Empty GameObject. The Empty GameObject is called “Tree1” and has 3 child Gameobjects: a Sprite called TreeTrunk, and 3 Wavy Sprites called Leaves1, 2, & 3.

The script should work(I think), but doesnt.

using UnityEngine;
using System.Collections;

public class TreeScript : MonoBehaviour {

	public GameObject[] leaves;

	void OnTriggerEnter (Collider other)
	{
		Debug.Log("Player has entered the trigger");

		if (other.gameObject.tag == "Player")
		{
			foreach (GameObject leafLayer in leaves) {
				leafLayer.GetComponent<WavySprite>().tint.a = 50;
			}

		}
	}

	void OnTriggerExit (Collider other)
	{
		Debug.Log("Player has exited the trigger");

		if (other.gameObject.tag == "Player")
		{
			foreach (GameObject leafLayer in leaves) {
				leafLayer.GetComponent<WavySprite> ().tint.a = 255;
			}
		}
	}
}

But I’m not sure why this isnt working, I get no error. The Debug puts out when I’m under the tree or not, but the Leaves wont go transparent. Any suggestions?

@Yehsuah

Access the sprite renderer then the material and then the color of the material and change a to 0.

About the second question use this script to detect hovering over a certain collider:

 Ray ray;
     RaycastHit hit;
     
     void Update()
     {
         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         if(Physics.Raycast(ray, out hit))
         {
             if (hit.collider == myCollider) {
                 Debug.Log("Hi");
             }
         }
     }

OnMouseOver() is called every frame. Use OnMouseEnter() to make your collider bigger and OnMouseExit to make it smaller. There’s no need to have anything in Update here.