Wrong object always Instantiated

Okay, so I’m working on a system where if a player destroys an object, they may then place duplicates of that item. If no object has been destroyed, an empty object, or airBlock, is placed. I’m currently having an issue where no matter what, the empty object is always placed instead of the intended block. The following script is on every block, and handles destroying the objects and the like.

var targeted : boolean = false;
var destroyOrPlace : int = 1; //1 = null, 2 = place, 3 = destroy
var delayTicks : int = 0;
var objToLoad : GameObject;
public var delayTotal : int;
public var dirtBlock : GameObject;
public var stoneBlock : GameObject;
public var nullBlock : GameObject;

function Update () {
	if (targeted == true){
		if (destroyOrPlace == 3)
		{
			delayTicks = delayTicks + 1;
			Debug.Log("ticks updated ");
		} else if (destroyOrPlace == 2)
			{
				delayTicks = 0;
				Instantiate(MainScript.inventoryStore[MainScript.selectCol, MainScript.selectRow], transform.position, transform.rotation);
			}

	} else {
		delayTicks = 0;
	}
	if (delayTicks == delayTotal) {
		if (MainScript.inventoryStore[MainScript.inventoryCol, MainScript.inventoryRow] == null){
			if (gameObject.name == "Dirt-Block (Clone)"){
				objToLoad = dirtBlock;
				MainScript.inventoryStore[MainScript.inventoryCol, MainScript.inventoryRow] = objToLoad;
			} else if (gameObject.name == "Stone-Block (Clone)"){
				objToLoad = stoneBlock;
				MainScript.inventoryStore[MainScript.inventoryCol, MainScript.inventoryRow] = objToLoad;
			} else if (objToLoad == null) {
				objToLoad = nullBlock;
				MainScript.inventoryStore[MainScript.inventoryCol, MainScript.inventoryRow] = objToLoad;
			}
		}
		Destroy(gameObject);
		Debug.Log("Destroyed");
	}
}

Any help would be greatly appreciated, and I’m more than happy to provide additional information.

Please provide additional information like what delayTotal you pass and when player destroy object which function is called on destroying object. though despite of all these information i think the problem is in inventory because when you want to instantiate object you go to inventory and fetch object by row and colom. So either inventory is getting wrong number or you havent set value for invetoryRow and colom.