Destroy Other

I want to make it so that when the player touches this object, it destroys a different object.

I attach this script to the trigger, so that way when the player touches this trigger, a separate object called “Sucks2” is destroyed.

function OnTriggerEnter(other : Collider) {
    if (other.tag == "Player") {
        Destroy(gameObject.name == "Sucks2");
    }
}

but I get this error message:
“BCE0020: An instance of type ‘UnityEngine.Object’ is required to access non static member ‘name’.”

why? how do I fix this?

Change:

  Destroy(gameObject.name == "Sucks2");

To:

  Destroy(GameObject.Find("Sucks2"));

Note this line of code will cause problems if no game object with ‘Sucks2’ name is in the scene.

Change:

  Destroy(gameObject.name == "Sucks2");

To:

  Destroy(GameObject.Find("Sucks2"));

Note this line of code will cause problems if no game object with ‘Sucks2’ name is in the scene.