A namespace can only contain types and namespace declarations

void Start () {
GameObject go = GameObject.FindGameObjectWithTag(“Player”);
target = go.transform;

I keep getting the namespace error on this line of code and I’ve tried to fix it for the past 2 hours but can’t. A little help would be appreciated.

All the code needs to be inside the MonoBehaviour { } brackets,or els it wont work,smartypants. its the same as HTML. it all needs to be inside the main block.
thats how it works.

your code was outside of the MonoBehaviour {} brackets.
as this was a simple cut and paste fix , i did the fixing for you.
(if its still relevant)

 using UnityEngine;

using System.Collections;

public class EnemyAI : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int rotationSpeed;

void Start () {
GameObject go = GameObject.FindGameObjectWithTag(“Player”);
target = go.transform;**

}

void Update () {
Debug.DrawLine(target.position, myTransform.position, Color.yellow);**

     //Look At Target
     myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);

    //Move Towards Target
   myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;

}

}

You can’t use C# like that; it must be in a class that extends MonoBehaviour (plus you need to import the UnityEngine namespace). If you want simpler coding that doesn’t require that kind of boilerplate code, you’d be better off with Unityscript.

I know that but this is just a snippit of code. Here’s the full code.

 using UnityEngine;
using System.Collections;

public class EnemyAI : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed;
}
	
	**void Start () {
		GameObject go = GameObject.FindGameObjectWithTag("Player");
		target = go.transform;**
		
	
	}
**void Update () {
		  Debug.DrawLine(target.position, myTransform.position, Color.yellow);**
		
		  //Look At Target
		  myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
	
		 //Move Towards Target
		myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
		
	}

The lines that have the error gave the ** on them.