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;
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.
Are you talking about JavaScript, or is there another language in Unity besides JavaScript and C#?
If you look closely, you don't have most of your code inside the public class EnemyAI : MonoBehaviour brackets. That is the part of the code that actually gets runned and if you don't have your code in there you will get an error.
In my case it was uncommented word
– kapyarclassin the code