How do i delete a gameObject if it enters a box collider using tags

I have tried to make a JavaScript that deletes a certain gameObject when it falls into a box collider.

Function OnTriggerEnter (other : Collider)
  if (gameObject.tag == "block")


This is the script that i use.

notice : i already tag the block that i want to destroy with the tag : block.

And in the picture you see i also created another gameObject named, 0-Destroy Platform. It got a Box Collider and “Is Trigger” is selected.(the green square area is the size of the collider) I also know that i have to put the script into this gameObject.

In short : how can i destroy the block when the block hits the box collider.

What did i wrong?

Ensure that the blocks have a rigidbody. Also, I believe in javascript it is function with a lower case ‘f’ (not Function).

Also, the script needs to be on the trigger and you need to change the line to:

if (other.gameObject.tag == "block")

Try this:

    function OnTriggerEnter (other : Collider)
      if (other.gameObject.tag == "block")