"Object Reference not set to an instance of an object" What does it mean?

Alright, so I have this bit of code set up, which helps my character attack things.
When I press the “A” key, and left click on the screen, I set my character to attack that point on the screen.
Everything goes well up until he gets within attack range. The attack instance, attackPrefab, does not actually appear where it should. Here is my code:

using UnityEngine;
using System.Collections;

public class gladiator_combat_script : MonoBehaviour
	public GameObject character;
	private gladiator_base_stats stats;
	bool attackingClick = false;
	public bool attacking = false;
	float targetDistance;
	Vector3 attackTrue;
	public GameObject attackPrefab;
	public GameObject movePoint;

	void Update()
			attackingClick = true;

		if (Input.GetMouseButtonDown (0))
		if(attackingClick == true)
			RaycastHit attackPoint;
			Vector3 attackPos = Input.mousePosition;
			attackPos.z = 25f;
			Debug.Log(Camera.main.ScreenToWorldPoint (attackPos));
			attackTrue = Camera.main.ScreenToWorldPoint (attackPos);
			Physics.Raycast (Camera.main.transform.position,attackTrue, out attackPoint);
			Debug.Log (attackPoint);
			movePoint.transform.position = new Vector3(attackTrue.x, -0.45f, attackTrue.z);
			attacking = true;

		if (attacking == true)
			targetDistance = Vector3.Distance(transform.position,attackTrue);
			Debug.Log (targetDistance);
			if (targetDistance < stats.attackRange)
				if (stats.attackCooldown == 0f)
				Rigidbody attackInstance;
				stats.attackCooldown = Time.deltaTime * 1;
				attackInstance = Instantiate(attackPrefab, attackTrue, character.transform.rotation) as Rigidbody;

Which means this line: “if (targetDistance < stats.attackRange)” should be the source of error. Does anyone know how to make the attackPrefab actually GET created?

Same info as everyone else. You are using stats (which is a reference/instance of gladiator_base_stats) but you have not fully declared it as an instance before using it. You are currently using it as if it is a value type.,

As other have said you don’t actually instantiate (read “create”) stats so when you try and reference it it isn’t there.

Depending on where the stats are supposed to come from you have a few options:

A: If you only want to check attack range after some other part of your code has instantiated and initialised gladiator_combat_script.stats then wrap the offending code in a null check:

if( this.stats != null )
/// do stuff

This could include making it public and assigning it through the editor, IF it is a monobehaviour…

B: as others have say you simply need to instantiate stats:
// Either do it when you declare it
private gladiator_base_stats stats = new gladiator_base_stats();

// Or, as other have said do it in start
void Start()
     stats = new gladiator_base_stats();
// do any initialisations