print(var a = object) = null while print(oject) = what i want

Why isn’t this code working when i try to print out tileRight it says null

its all in start function so i can declare all this before the game starts, they are all pretty much global vars to

var monsterOnMe : GameObject;
var tileRight : GameObject;
var tileUp : GameObject;
var tileLeft: GameObject;
var tileDown : GameObject;
var floorMap : GridMaker;

var myX;
var myY;
var xNext: int;
var yNext: int;
var xBack: int;
var yBack: int;

var canPlace : boolean;
var getGridPoint : GuiStart;

function Start () 
{
	canPlace = true;
	// see if towers can be placed on that gridfloor
	getGridPoint = GameObject.Find("Controller").GetComponent(GuiStart);
	
	//Make Sure Controller is always called Controller!!!!
	var findTotalRows = GameObject.Find("Controller").GetComponent(GridMaker);
	floorMap = GameObject.Find("Controller").GetComponent(GridMaker);
	
	
	for(var i : int = 0; i < findTotalRows.gridX; i++)
	{
		for (var j : int = 0; j < findTotalRows.gridY; j++)
		{
			if(floorMap.map[i,j].name == this.name)
			{
				myX = i;
				myY = j;
			}
		}
		
	}
	xNext = myX + 1;
	yNext = myY + 1;
	xBack = myX - 1;
	yBack = myY - 1;
	
	tileUp = floorMap.map[myX,yNext];
	tileDown = floorMap.map[myX,yBack];
	tileLeft = floorMap.map[xBack,myY];
	tileRight = floorMap.map[xNext,myY]; 
}

hope this makes more sense now.

GridMaker.JS

var instantiateObject : GameObject;

var gridX = 10;
var gridY = 10;
var map : GameObject[,];

function Start () {
	map = new GameObject[gridX,gridY];
	for ( var x = 0; x < gridX; x++){
		
		for (var y = 0; y < gridY; y++){
		
			var myName = Instantiate(instantiateObject, Vector3(x *.5,0,y * .5), Quaternion.identity);
				
			myName.name = "x: " + x + "y: " + y;
			
		map[x,y] = myName;
			
			
			
		//Debug.Log(map[x,y]);
		}
		
 	} 
		
}

GuiStart.JS


var gridPoint : GameObject;


	// do raycast
	var hit : RaycastHit;
    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
      if ( Physics.Raycast( ray, hit, 100 ) ){

        if (hit.collider.CompareTag("gridFloor")){

           gridPoint = hit.collider.gameObject;

			}
		}

I think I can see the problem here- do you think maybe the Start functions aren’t getting called in the right order? It isn’t necessarily defined what order Start functions happen in unless you manually specify it in the ‘Script Execution Order’ settings.

Are your values dependent on something which happens in the GridMaker’s start function? If so, try changing the GridMaker’s ‘Start’ to ‘Awake’ to make sure it executes first. You can also set it up in the script exectuion order settings, which I mentioned earlier. These can also fix problems which arise in Update for similar reasons.

Why are you using GameObject.Find() to assign your variables?

That seems like a bad idea to me... My guess is you do not want to do this.

Even if you did want to use this approach, it looks like you're doing it wrong.

This line looks questionable:

getGridPoint = GameObject.Find("Controller").GetComponent(GuiStart);

Here's how I would interpret that code:

Look for a GameObject in the scene with the name "Controller". If there is such a GameObject, check to see if it has a script named GuiStart attached to it. If it does, return a reference to that script. If it does not, return null.

Even if your script IS attached to a GameObject that has a script named GuiStart attached to it, I think your script would fail. My guess is your trying to do too much conversion between incompatible types in one step... In my humble opinion that line of code is ALL bad. You're trying to do too many things in one step and you never test if any of them succeed. Beyond that I would argue that there is no reason to use GameObject.Find() to begin with...

It seems to me that it would be much easier to assign your variables using the Inspector...

Wouldn't it be easier to assign getGridPoint by dragging and dropping a GameObject (that has a GuiStart script attached to it) in the Inspector?