2D platformer player mouse rotation

Ive tried to do this but I cant get it ok. How can I rotate the player when to left when the mouse cursor is in the left side of the screen and to rotate it right when the mouse cursor is in the right of the screen?

Ive tried to modify the PlatformerController script*

Thank you!

var playerPlane = new Plane(Vector3.forward, transform.position);
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
var hitdist = 0.0;
if (playerPlane.Raycast (ray, hitdist)) {
var targetPoint = ray.GetPoint(hitdist);
var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
transform.rotation = targetRotation;
transform.rotation.z = 0;
transform.rotation.x = 0;

So how do I add this? The first three lines in the first part of teh script and the others in the Update?

Everything in update… create a new javascript script file, and that will be the text. Name it “Lookatmouse.js” and insert in your player object.

Again:

Lookatmouse.js

function Update () {
    var playerPlane = new Plane(Vector3.forward, transform.position);
    var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    var hitdist = 0.0;
    if (playerPlane.Raycast (ray, hitdist)) {
        var targetPoint = ray.GetPoint(hitdist);
        var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
        transform.rotation = targetRotation;
		transform.rotation.z = 0;
		transform.rotation.x = 0;
    }
}

NullReferenceException on

var ray = Camera.main.ScreenPointToRay (Input.mousePosition);

Make sure the game object your main camera is attached to is tagged as ‘MainCamera’.