Casting a Ray at the Mouse Position

Hi there, apologies if this has already been answered, but I couldn’t find a solution in my search.

I’m trying to make a top down shooter, and am having trouble using a ray cast for shooting.

I’ve trying to use this:

function Shooting() {
	if (Input.GetButtonDown("Fire1")) {//Left Click
		var lineStart : Vector3 = this.transform.position;
		var lineEnd : Vector3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
		Debug.DrawLine( lineStart , lineEnd , Color.red); //using draw line in place of a linecast until I get it working
	}  
}

But what that does is draw the line from the camera instead of the mouse position.

I tried using World to Screen Point, but what that did was only use the pixel co-ordinates, and cast at a 90 degree angle from the player.

Thanks in advance.

Use this

	void Update()
	{
		
                        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    	
			RaycastHit hit ;
		
	                         if (Physics.Raycast (ray, out hit)) 
					{
	                                        if(hit.collider.gameObject.tag =="Test")
							{
								Debug.Log("TEST");			
							}
				  	}

	}