Raycast question

So ive made a grid out of cubes with two seperate scripts attached to it. One to highlight the cube by changing its color, the other is a raycast 1.0 high going up. what im wondering is how to i make a non rigid body cube spawn at the top of the point of the raycast.

code for Raycast:

using UnityEngine;
using System.Collections;

public class CubeRaycast : MonoBehaviour {
	
	
	public RaycastHit hit;
	
	public GameObject Cube;
	
	public float range = 1.0F;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		
	Vector3 DirectionRay = transform.TransformDirection(Vector3.up);
	
		Debug.DrawRay(transform.position, DirectionRay * range, Color.red);
		
	if (Physics.Raycast(transform.position, transform.up, out hit, 1F))
{
		if(Input.GetKeyDown(KeyCode.Mouse0)){
			
			range += 1.0F;
				
				GameObject instanceCube = Instantiate(Cube,hit.point,transform.rotation)as GameObject;
			
			
			}
		
		}
	
	}
}

Once again. DrawRay and Raycast are two different things. The first is used for debugging, the other actually does the job. They work gret together for visualizing your ray but only if you set them up correctly to point in same direction.

In your code you have:

Debug.DrawRay(transform.position, DirectionRay * range, Color.red);
Physics.Raycast(transform.position, transform.up, out hit, 1F))

So you are drawing a ray in “DirectionRay” direction, but you are raycasting up the y axis of the object your script is in. Do:

Physics.Raycast(transform.position, DirectionRay , out hit, range))

This way you can visualize your ray. Your instantiation code looks ok.