Setting Target For Enemy Inside AI?

Hello,
So I have a transform target and I need to set the target to ym main camera?
How can I do this?
This code gives me the cannot implicitly convert transform into GameObject.
Thanks

using UnityEngine;
using System.Collections;

public class AdvancedAI : MonoBehaviour
{
    float distance;
  
    public float lookAtDistance = 25.0F;
    public float chaseRange = 2050.0F;
    public float attackRange =4.5F ;
    public float moveSpeed = 5.0F;
    public float damping = 6.0F;
    public float damage = 30.0F;
    public float attackRepeatTime = .8F;
    public Transform target;
    public CharacterController controller;
    private float verticalMomentum = 0f;
    private float gravity = -9.8f;
  
    private Vector3 moveDirection = Vector3.zero;
    private float attackTime;



    //TODO: add in a function to find controller and to locate and assign the player as the target
  
    void Start()
    {
        attackTime = Time.time;
        target = GameObject.FindWithTag("MainCamera");
    }
  
    void Update()
    {
        distance = Vector3.Distance(target.position, transform.position);
        verticalMomentum += gravity * Time.deltaTime;
      
        if(distance < lookAtDistance)
        {
            LookAt();
        }
      
        if (distance < attackRange)
        {
            AttackPlayer();
        }
      
        else if (distance < chaseRange)
        {
            ChasePlayer();

        }
    }
  
    void LookAt()
    {
        Quaternion rotation = Quaternion.LookRotation(target.position - transform.position);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
    }
  
    void ChasePlayer()
    {
        moveDirection = transform.forward;
        moveDirection *= moveSpeed;
        moveDirection.y += verticalMomentum * Time.deltaTime;
        controller.Move(moveDirection * Time.deltaTime);
    }
  
    void AttackPlayer()
    {
        //TODO: Need Attack Animations
        if (Time.time > attackTime)
        {
            target.SendMessage("damagePlayer", damage, SendMessageOptions.DontRequireReceiver);
            attackTime = Time.time + attackRepeatTime;
        }
    }
  
    void ApplyDamage()
    {
        chaseRange += 15;
        moveSpeed += 1;
        lookAtDistance += 20;
    }
}

@ecloev

you have defined your target as transform, define it to gameobject.

using UnityEngine; using System.Collections;

public class AdvancedAI : MonoBehaviour { float distance;
	
	public float lookAtDistance = 25.0F;
	public float chaseRange = 2050.0F;
	public float attackRange =4.5F ;
	public float moveSpeed = 5.0F;
	public float damping = 6.0F;
	public float damage = 30.0F;
	public float attackRepeatTime = .8F;
	public GameObject target;
	public CharacterController controller;
	private float verticalMomentum = 0f;
	private float gravity = -9.8f;
	
	private Vector3 moveDirection = Vector3.zero;
	private float attackTime;
	//TODO: add in a function to find controller and to locate and assign the player as the target
	
	void Start()
	{
		attackTime = Time.time;
		target = GameObject.FindWithTag("MainCamera");
	}
	
	void Update()
	{
		distance = Vector3.Distance(target.transform.position, transform.position);
		verticalMomentum += gravity * Time.deltaTime;
		
		if(distance < lookAtDistance)
		{
			LookAt();
		}
		
		if (distance < attackRange)
		{
			AttackPlayer();
		}
		
		else if (distance < chaseRange)
		{
			ChasePlayer();
		}
	}
	
	void LookAt()
	{
		Quaternion rotation = Quaternion.LookRotation(target.transform.position - transform.position);
		transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
	}
	
	void ChasePlayer()
	{
		moveDirection = transform.forward;
		moveDirection *= moveSpeed;
		moveDirection.y += verticalMomentum * Time.deltaTime;
		controller.Move(moveDirection * Time.deltaTime);
	}
	
	void AttackPlayer()
	{
		//TODO: Need Attack Animations
		if (Time.time > attackTime)
		{
			target.SendMessage("damagePlayer", damage, SendMessageOptions.DontRequireReceiver);
			attackTime = Time.time + attackRepeatTime;
		}
	}
	
	void ApplyDamage()
	{
		chaseRange += 15;
		moveSpeed += 1;
		lookAtDistance += 20;
	}
}