Z position moving in 2D space

I am trying to make a system to move a sprite around in 2D space by getting the mouse X and Y, but the sprite is moving around in the Z axis causing the sprite to not be visible. My code is,

player.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y, 0.0f));
(It should be all in one line but it isn’t.) Please help.

This should work:

transform.position = (Vector2) Camera.main.ScreenToWorldPoint(Input.mousePosition);

You may leave out (Vector2).