Making a simple grid

Hi ive decided to make a grid from objects ie alot of squares connected together, i would like to have objects spawned on the individual sqaures by using the mouse click these objects need to appear on the center on the square only, but at the moment they are going anywhere any ideas on a solution?

var myCam : Transform;
var maxDistance : int = 50;

var dirtBlock : Transform;


function Update(){

	Screen.lockCursor = true;

	var ray = new Ray(myCam.position, myCam.forward);
	var hit : RaycastHit;
	
	if(Physics.Raycast (ray, hit, maxDistance)){
	
		if(Input.GetKeyDown(KeyCode.Mouse1) && hit.transform.gameObject.tag != "BuildingBlock"){
		
			var hitPointX : int = hit.point.x;
			var hitPointZ : int = hit.point.z;
			
			print("Hit point: (X: " + hitPointX + ", Z: " + hitPointZ);
		
			Instantiate(dirtBlock, Vector3(hitPointX + 0.5, 0.5, hitPointZ + 0.5), Quaternion.identity);
		}
		
		if(Input.GetKeyDown(KeyCode.Mouse0) && hit.transform.gameObject.tag != "Terrain"){
			
			Destroy(hit.transform.gameObject);
		}
	}
}

Take a look at this code. By making a single terrain and an (1, 1, 1) sized block prefab, you can spawn those blocks on the invisible grid. Ofcourse you need to modify the code a little bit for it to work the exact way you want, but thats the basics of how you spawn on grid very easily.

Hope you find this usesful!

try starting with the basics here Make a Grid in Unity 5.5! - YouTube