java script error

This is the script can nayone fix the error

static var comehome: boolean = false;

static var runaround: boolean = true;

var speed:float = 20; var rotatespeed:float = 10; var dis:float = 1; var LeftRight:float = 2; var infront:float = 1; var home : String; private var direction:float = 60;

function Start() { var home =gameObject.FindWithTag(home); } function Update(){ if(comehome){ //transform.LookAt(home); transform.LookAt(home.transform, Vector3.up); transform.Translate(Vector3.forward*speed*Time.deltaTime); }

if(runaround){

if(!Physics.Raycast(transform.position, transform.forward, infront)){
        transform.Translate(Vector3.forward * speed * Time.deltaTime);
    }
    else{
        if(!Physics.Raycast(transform.position, -transform.right, LeftRight)){
            direction = 60;
        }
        else if(!Physics.Raycast(transform.position, transform.right, LeftRight)){
            direction = -60;
        }
        transform.Rotate(Vector3.up, 60 * rotatespeed * Time.deltaTime * direction);
    }

} }

this is the error

BCE0019: 'transform' is not a member of 'String'.

Try:

transform.LookAt(home.transform, Vector3.up);

As I mentioned in my last comment. You could save some performance if "home" is the same game object at all times. Like this:

```

`var home : GameObject;
var comeHome : boolean = true;

function Start()
{
    home = gameObject.FindWithTag("home");
}

function Update()
{
    if (comeHome && home != null)
    {
         transform.LookAt(home.transform);
         transform.Translate(Vector3.forward * speed * Time.deltaTime);
    }
}

```

`

You see the difference? Now "home" is a string, which is the tag name. Whereas the variable home is of the type GameObject.

As you probably know. String is just a bunch of letters or chars ('a', 'b', 'c'), whereas GameObject is a class. With an instance of GameObject (also known as an object), you can refer to the transform of the game object. Transform is required of the: `transform.LookAt(Transform)` method.