Problem with Taping Script

I created a GameController, and its job is to spawn by sprite. Now I want to destroy the spawns with just a single tap.

This is the script that attached to the main camera:

if (Input.touchCount > 0)
 
    {
 
        var hit : RaycastHit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint((Input.GetTouch(0).position)), Vector2.zero);
 
 
 
        if(hit.collider != true)
 
        {
 
            Destroy(hit.transform.gameObject);
 
        }
 
    }

Then I attached the script below to the prefab that I inserted into the GameController:

function OnTriggerEnter(other:Collider){
 
    Destroy(other.gameObject);
 
}

I even added box colliders to the GameController, Prefab, and Main Camera; they are all triggers. What am I doing wrong?

OnTriggerEnter gets called, when 3d rigidbody-enabled game-objects enter your 3d-trigger.
For 2d-games, there is OnTriggerEnter2D.
It will get called when 2d game-objects enter your 2d-trigger. Is that the case?

Do you really need your camera script?

if(hit.collider != true)

means (if it works at all), that you want to destroy the hitobject, when there is none?

Are you stating that the my prefab that’s in the gameController is not being detected?