Raycast not working with instantiated objects.

Hello, this is my first question on the forums. I was looking all over the internet,but I found no answer. I am making a game, which should generate land as you walk. Heres my code:
var land : GameObject;
var xpos : float;
var zpos : float;
var xuse : float;
var zuse : float;

function Update () {
xpos = transform.position.x / 50;
zpos = transform.position.z / 50;
xuse = Mathf.Round(xpos) * 50;
zuse = Mathf.Round(zpos) * 50;
var hit : RaycastHit;

if (!Physics.Raycast (Vector3(xuse,1,zuse), Vector3(xuse,-1,zuse), hit, 5.0)) {
		Instantiate(land,Vector3(xuse,0,zuse),Quaternion.identity);
		print("Land instantiated");
	}
else {
	if (hit.transform.tag == "Land") {
		print("Land found");
		}
	}
}

This might not be most efficent way to do it, but anyways. So when I walk it generates ground below me on a grid of 50. The problem is when it raycasts and finds nothing below it generates ground, but it doesnt detect it with raycast so it keeps infinitley generating it. I found on another post that checking for tags, but this isn’t working since its kind of opposite. I really have no idea what to do. Waiting for any answers.

Okay, all fixed :slight_smile: Thanks to robertbu, I tried using Debug.DrawRay and I found out my ray was facing completely wrong direction. Everything is fixed now. If anyone is interested in the script then here ya go:
var land : GameObject;
var xpos : float;
var zpos : float;
var xuse : float;
var zuse : float;
var tr : Vector3;

function Update () {
xpos = transform.position.x / 50;
zpos = transform.position.z / 50;
xuse = Mathf.Round(xpos) * 50;
zuse = Mathf.Round(zpos) * 50;
tr = Vector3(xuse,1,zuse);
var hit : RaycastHit;

if (!Physics.Raycast (tr, Vector3(0,-1,0), hit, 5.0)) {
		Instantiate(land,Vector3(xuse,0,zuse),Quaternion.identity);
		print("Land instantiated");
		Debug.DrawRay(tr, Vector3(0,-1,0), Color.white, 5.0);
	}
else {
	print("Something in the way");
	Debug.DrawRay(tr, Vector3(0,-1,0), Color.white, 5.0);
	}
}