unity Javascript 变换对象进不去

Unity Javascript transform object not able to go in

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)
{
    lookAt();
}

if (Distance > lookAtDistance)
{
}

if (Distance < attackRange)
{
    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);
}

我试图让我的物体朝向玩家,但我无法将任何东西放入提示您放置我希望它跟随的物体的插槽中 我认为问题出在第 2 行,但我已经尝试了很多东西,但我无法做任何事情来解决它 我想指出我在不同的脚本中有另一段类似的代码,它工作得很好。

将第 2 行的 var Target = transform; 替换为 var Target:Transform;