This function will work only when your mouse is on object collider. Just read this unity stuff - https://docs.unity3d.com/6000.0/Documentation/ScriptReference/MonoBehaviour.OnMouseDrag.html
Might be your mouse x value is zero. Try with delta value.