basic error and formatting help

So i made this code, but when i run the game i get these errors

UnassignedReferenceException: The variable LastSaw of ‘LookAtUpdated’ has not been assigned.
You probably need to assign the LastSaw variable of the LookAtUpdated script in the inspector.
LookAtUpdated.AIStart () (at Assets/game/scripts/ai/enamie/basic/LookAtUpdated.js:68)

InternalGetGameObject can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

ArgumentException: InternalGetGameObject can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

UnityEngine.Component.get_gameObject () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/UnityEngineComponent.cs:171)
LookAtUpdated…ctor () (at Assets/game/scripts/ai/enamie/basic/LookAtUpdated.js:12)

Now i have read that i need to move something to the main thread, but being new i have no clue which is the main thread.

I don’t just want the code fixed, or if you do fix it, please tell me what i did wrong, and how to look for it.
also any formatting errors i made, or what might be better

#pragma strict

var Damping = 6.0;

private var Aware : boolean = false;

var hit : RaycastHit;

var rotation:Quaternion;

var SetEndTime = 0;

var EndTime = 0;

private var Timer = 0;

private var WasAware = false;

var SavedTime;

private var secondsSaved = 0;

var LastSaw = gameObject;

function Start()
{

InvokeRepeating("AIStart", Random.Range(0, 1.0), 0.01);

}

function AIStart ()
{

var seconds : int = Time.time;

if (Physics.Raycast (transform.position, transform.forward, hit, 100)
&& hit.transform.gameObject.tag == "Player")
{
	
	
	var DistanceFromPlayer = hit.distance;

	rotation = Quaternion.LookRotation(hit.transform.position - transform.position);
	
	if (DistanceFromPlayer <= 20)
	{
		transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
		Aware = true;
		LastSaw = hit.transform.gameObject;
		Timer = seconds;
	}
	else if (DistanceFromPlayer <= 30 && WasAware)
	{
		transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
		Aware = true;
		Timer = seconds;
	}
	
}
else if (Aware && secondsSaved <= EndTime )
{
	secondsSaved = seconds;
	EndTime = Timer + SetEndTime;
	var rotationFallow = Quaternion.LookRotation(LastSaw.transform.position - transform.position);
	transform.rotation = Quaternion.Slerp(transform.rotation, rotationFallow, Time.deltaTime * Damping);
	
}
else
{
	Aware = false;
	WasAware = true;
	secondsSaved = 0;
	seconds = 0;
	EndTime = 10;
}

}

The way you are assigning your “LastSaw” variable is not correct. You must do it inside a method. Like inside “Start()” or “AIStart()”, because you cannot access “gameObject” outside a method.