This is confusing, because the z rotation has no relation to the x and y coordinates of the mouse. when i do lookat, it doesnt work because of coordinate incompatibility.
You will have to use
Vector3 mousePos = Input.mousePosition;
//To make mousePos relative to center of screen
mousePos.x -= Screen.width / 2;
mousePos.y -= Screen.height / 2;
//To make mousePos relative to transform
mousePos += transform.position;
angle = Vector3.Angle(mousePos, Vector3.up);
//For 360 degree angle
if (mousePos.x > 0)
angle = 360 - angle;
transform.rotation = Quaternion.Euler(0, 0, angle);
Add this to your main player script in Update or FixedUpdate (better).
Result:
Sorry for the upside down arrow! It was like that originally.