C# LookAt Mouse 2D

Hello, i’m trying to do a code to player look at mouse, but i’m a beginner and don’t know how to do it exatly, here is my code:

using UnityEngine;
using System.Collections;

public class PlayerBehaviour : MonoBehaviour {

	public Transform target;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

		transform.LookAt(target);
	
	}
}

I need to put mouse in target, but how? Or i need to do other code? Somebody can save me with that? I’m using C#, thanks =(

And sorry for my bad english

Try this:

void Update() {
    Vector3 dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
    float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}

You need to get the mouse position relative to the game screen, and always on Update function make your character turn around looking the mouse pointer.

See Mouse Position, Rotate, and other things