Why am i getting a null reference?

My Script is:

void DestroyBlock ()
		if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, range))
			if (hit.collider.transform.parent.tag == "Block")
				Vector3 hitPos = hit.collider.transform.parent.transform.position;
				int x = (int) hitPos.x;
				int y = (int) hitPos.y;
				int z = (int) hitPos.z;
				Destroy(levelData[x, y, z].gameObject); *** this is where the error is
				dataScript.levelData = levelData;

null reference exception: object reference not set to an instance of an object

levelData[x, y, z] is throwing an error because you never declared the variable. Also you need to set data into the array. It is likely that where you are populating the data, one of the objects is null. Given the code you posted, there is no way for us to provide further help.

The code you posted is where you see the error, but not where the error is caused. You will need to post the code where the array is declared, and the values are set into the array, then we may be able to help.