title: Instantiate Object at mouse position
body: <p>I have created a script which was supposed to instantiate gameobject according to mouse position but something has went wrong. And it is only being instantiated at one position and in the middle of the screen.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class LineInstantiater : MonoBehaviour {
  
      public GameObject lineprefab;
      private GameObject linehandler;
      private Vector3 mousepos;
  
      void Update(){
          if (Input.GetMouseButton (0)) {
              mousepos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
              linehandler = Instantiate (lineprefab,Camera.main.ScreenToWorldPoint(Input.mousePosition),Quaternion.identity) as GameObject ;
              linehandler.transform.position = mousepos;
          }
      }
  
  }
  </code></pre>
  
  <p>Please tell me what is wrong with my script. </p>