Three errors in my Java Script

Hi, i’m really new to this forum so i hope that i post things right. I’ve been following a tutorial on a script for an AI to follow you and change colors depending on the distance, i kept stumbling into the same errors.

Assets/AISimple.js(32,84): BCE0043: Unexpected token: ).
Assets/AISimple.js(32,65): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/AISimple.js(32,64): BCE0044: expecting ), found ‘=’.

Here’s the code

var Distance;
var Target : Transform;
var lookAtDistance = 25.0;
var attackRange = 15.0;
var moveSpeed = 5.0;
var Damping = 6.0;

function Update ()
{
    Distance = Vector3.Distance(Target.position, transform.position);
   
    if (Distance < lookAtDistance)
    {
        renderer.material.color = Color.yellow;
        lookAt();
    }
   
    if (Distance > lookAtDistance)
    {
        renderer.material.color = Color.green;
    }
   
    if (Distance < attackRange)
    {
        renderer.material.color = Color.red;
        attack ();
    }
}

function lookAt ()
{
    var rotation = Quaternion.LookRotation(Target.position = transform.position);
    transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
}

function attack ()
{
    transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
}
var rotation = Quaternion.LookRotation(Target.position = transform.position);

You wrote “=” instead of “,” when passing paramaters. It should be

var rotation = Quaternion.LookRotation(Target.position, transform.position);

Thank you, it’s weird though, when i get close so the AI turns yellow, he flips, then when he gets red as i approach, he flies away from me as soon as he’s red, why?

Did you maybe want to calculate target.position - transform.position and pass it as the first parameter? Otherwise you may get unwanted and weird results. See: Quaternion.LookRotation
The second argument says which axis is considered to be the up-direction. You can use the one-parameter overloard if your up-direction is the same as Vector.Up.