Placing object with ray cast

I am trying to give a cube the position of a raycast hit(with the mouse pos). But when I connect the cube's position with the ray cast hit point, the cube goes back and forth along the ray's line.

Here is the code of the script that is connected to the cube:

function Update(){

    var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hit : RaycastHit;

    if (Physics.Raycast (ray, hit)) {

        Debug.DrawLine (ray.origin, hit.point);
        transform.position=hit.point;

    }

}

Do you have any other forces working on your cube? Because the code looks correct.

When I Erase the: transform.position=hit.point; The debug line works fine, but when I add that row the cube starts going back and forth along the ray, and the debug line is affected as well.

I tryed something like that:

function Update(){    
var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);    
var hit : RaycastHit;    
if (Physics.Raycast (ray, hit)) {        
Debug.DrawLine (ray.origin, hit.point);        
 Debug.Log(hit.point);
var xx=hit.point.x;
var yy=hit.point.y+0.55;
var zz=hit.point.z;
transform.position=Vector3(xx,yy,zz);
}}

And it works, but when i change the 0.55 val, to a lower num, it causes the same problem.