Set position flom RaycastHit.point

void Update () {
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out hit);
transform.position = hit.point;
}
The object moves from the hit point to the origin point teleports to the hit point and moves to the camera and again and again. I want it to stay at the hit point and only move when the hit point changes.

So my problem was that i had a collider on the cube that the raycast is hitting so my hit.point was moving every time its hitting the collider. Well thanks for the help and sorry for wasting you time.

wrap the raycast with an if and change the position in there. that’s the place where you know you hit something.