Can't seem to get OnMouseExit and Destroy(GameObject) to work properly

Hello folks, I’m fairly new to Unity and its’ architecture so excuse if the issue is fairly obvious, I just can’t seem to figure it out.

So here’s the deal: I’m trying to spawn Object X on top of Object Y whenever I hover Object Y with my mouse. When the mouse leaves Object Y’s collision it should destroy Object X. (sort of an highlight but with another object) I’ve already removed Object X’s collision box since it influenced Object Y’s OnMouse calls since it was under Object X. But anyways, here’s my code:

	public Transform selection;
	private Vector3 position;
	private GameObject selectionObject;

	public void OnMouseEnter() {
		position = transform.position;
		selectionObject = Instantiate(selection, position, Quaternion.identity) as GameObject;
	}

	public void OnMouseExit() {
		Destroy (selectionObject);
		Debug.Log ("Exited!");
	}

The Debug command seems to be logging the event correctly but the object isn’t destroyed, it just remains intact in the game world. Any help would be appreciated! Thank you!

you Instantiate have a transform in the GameObject parameter only add .gameObject at your “selection” transform.
this works very fine:

	public Transform selection;
	private Vector3 position;
	private GameObject selectionObject;
	
	public void OnMouseEnter() {

		position = transform.position;
		selectionObject = Instantiate(selection.gameObject, position, Quaternion.identity) as GameObject;
	}
	
	public void OnMouseExit() {
		Destroy (selectionObject);
		Debug.Log ("Exited!");
	}