Collide with all, not surposed to

I got this code

#pragma strict
static var Won : boolean = false;
function Start () {

}

function OnCollisionEnter2D( Collision2D )
    {
        if(gameObject.tag == "Goal")
            {
                Won = true;
                Movement.CannonPower = 1000;
            }
   
    }




function Update () {

}

And its activate the collide function even though the object there is colliding aint have the tag “Goal”

sure but this is not what you write in code^^.
you write

 if(gameObject.tag == "Goal")

it means if the gameObject which have this script attached have the tag “Goal” then should the if statement be true
you need to write:

function OnCollisionEnter2D(other : Collision2D)
    {
        if(other.gameObject.tag == "Goal")
            {
                Won = true;
                Movement.CannonPower = 1000;
            }

    }

I forgot that it was an collision not a collider ^^

Thanks for the respond.
I had changed it, and got this error message

Assets/Script/Victory.js(9,18): BCE0019: ‘tag’ is not a member of ‘UnityEngine.Collision2D’.

up

nobody?

If you are looking for help, always post the newest code you are working with here. Make sure that the error message line number and the line number of the script match.

@Dantus

Thank you for the advice.

Hello guys. After I have changed the script, to this code:

#pragma strict
static var Won : boolean = false;
function Start () {

}

function OnCollisionEnter2D(other : Collision2D)
    {
        if(other.gameObject.tag ("Goal"))
            {
                Won = true;
                Movement.CannonPower = 1000;
            }

    }




function Update () {

}

And I got this error:

This makes absolutely no sense:

other.gameObject.tag ("Goal")

Did you wanted to have this?

other.gameObject.tag == "Goal"

@Dantus
Yeah I proberly ment that. Im not so hardcore to Unity Programming.

If deleted the code and started on a fresh, and tried to make it so simple as possible and it was a succes.

The succes code look like this:

#pragma strict
static var Won : boolean = false;
function Start () {
}

function OnCollisionEnter2D(test : Collision2D) {
    Debug.Log("Collided"); // Inform if something had collided with object
    if(test.gameObject.tag == "Goal")
    {
    Debug.Log("!!!!!Winner!!!!!"); // Inform if the "Right" object had collided
    }
}