little problem with java script

ok so ime making a Ai for a racing game and i nead the car to turn so i thought ide use the on enter function but the If statment aint working and the look at isnt working.

var target : Transform;

function OnTriggerEnter (other : Collider) 
{
    if Collider.name == "carAI"
    {
        Collider.transform.LookAt(target);
    }
}

IF eror is

Assets/costom scripts/AI/AI turn 1.js(5,27): BCE0044: expecting ), found '='.

look at erors are

Assets/costom scripts/AI/AI turn 1.js(5,38): BCE0043: Unexpected token: ).

Assets/costom scripts/AI/AI turn 1.js(7,50): BCE0044: expecting :, found ';'.

1 Answer

1

There are a couple errors there, missing brackets and a typo

var target : Transform;

function OnTriggerEnter (other : Collider) 
{
    if (other.name == "carAI")
    {
        other.transform.LookAt(target);
    }
}

Collider should have been other, and you were missing the parentheses for the if

Yea that'll make it hard. Good luck with it.

–