Ai finding target after spawning

Edit* Updated the code with the now Working code for others to look at. )

ok, basically the problem I'm having is that there seems to be no way of getting the AI to target the player after it spawns. I've tried having it find the player tag, but unity always says that transform and gameobject can't work together. basically i just need the enemy to automatically find the player and attack. If anyone could help it would be greatly appreciated.

heres the code

static var health : float = 100.0;
var player = transform;
var speed = 5.0;
var chaseRange = 50.0;
var force = 1;
private var controller : CharacterController;

function Awake(){

    player = GameObject.FindWithTag("Player").transform;


function Start()
    controller = GetComponent(CharacterController);

function Update()
    if (player == null)
    animation.CrossFade ("Idle");

    var range = Vector3.Distance(player.position, transform.position);

    if (range <= chaseRange)
        var moveDirection : Vector3 = transform.TransformDirection(Vector3.forward);
        controller.Move(moveDirection * Time.deltaTime * speed);
        animation.CrossFade ("Walk");

function OnTriggerEnter(collision : Collider) {
    if(collision.gameObject.tag == "Player"){
        transform.Translate(0, 5, -3);
        animation.CrossFade ("Lunge");
        //print("push back");

function OnCollisionEnter(collision : Collision){
    //If it collides with the player's bullet, run the apply damage function
    if(collision.gameObject.tag == "BulletPlayer"){

var hitPoints = 10;

function ApplyDamage(){
    //subtract 5 hitPoints
    hitPoints -= 5;
    //if the remaining hitPoints are more than zero, do nothing
    if(hitPoints > 0){
    //if the remaining hitPoints are less than zero, run the die function
    if(hitPoints <= 0){

function Die(){

check the FPS tutorial, it features an AI that moves around til it sees the player, then attacks. you might want to use it as a base for your own

Add a function Awake to search for the tag player:

function Awake(){
player = GameObject.FindWithTag("Player").transform;

That way, the moment it spawns, the player is set.