RayCast set boolean true help ?

Hi Guys, i was wondering if someone could help me, basically i have a gameObject in my game called headstone. Now what this does is it hits the ground and gets back up. something like in the mario games. well i have created this boolean called hitfloor. I have said if the hitfloor boolean is equals to false then add force to the gameObject in the -Vector3.up. Now that works perfectly and i have created my own function for this and then i call this in the start function. I have made a variable called BackUp which slowly makes the stone go back up until it will reach its last know position and then hit down back. Now the thing is i have created a raycast in the update function which checks and sees if the stone has hit the floor using the ray. if it has i then want it to set the hitfloor boolean to ture so then it will check the function that contains the force to see if the boolean is true what to do. so in this case the object will start going back up. but this does not work because the ray is hitting the floor and the boolean is not being set as true. i have made sure that the ray is long enough but still not working. I have also told the system to give me a debug that the ray has hit the floor. And the message does not show up as well. you please guys can some one help me thanks you very much in advance :) MCHALO


var DownSpeed : float = 20;
var BackUpSpeed : float = -3;
var StopDownSpeed : float = 0;

var hitfloor : boolean = false;
function Start () {

DropStone ();

function Update (){

  var hit: RaycastHit;

      Debug.DrawRay (transform.position,-Vector3.up * 5, Color.red);
      if(Physics.Raycast(transform.position , -Vector3.up , hit, 5)){

           if(hit.collider.gameObject.tag == "ground"){

           hitfloor = true;
                          Debug.LogError("you have hit the floor");

      DropStone ();

function DropStone (){

  if(hitfloor == false){
  rigidbody.AddForce(-Vector3.up * DownSpeed );
if(hitfloor == true)

rigidbody.AddForce(-Vector3.up * -BackUpSpeed );



On first glance the code looks fine to me. Are you sure the ground is tagged "ground" and not "Ground"? Because that's a common mistake. Other then that, just to let you know, when using booleans instead of saying if(a == true) and if(a == false) you can just say if(a) and if(!a).