Player moves to the middle of the room when the level starts (2d point and click)

Hi! I am new to Unity and I found this script online for moving the player using mouse input. But every time the level starts the player moves to the center of the scene. I’m not sure how to keep it where I placed it during setup. Please help! (Unity 2018.2.7f1, 2D)
My code:

public class MovePlayer2 : MonoBehaviour {

    public Vector2 targetPosition;
	[SerializeField]
	private Rigidbody2D rb;
	[SerializeField]
	private float speed = 10;
    // Update is called once per frame
    void FixedUpdate () {
 
        if(Input.GetMouseButtonDown(0)) { //checks that the left mouse button has been pressed
            targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); //sets the targetPosition to the dimensional point in the game where the mouse clicked

		}
        transform.position = Vector2.MoveTowards(transform.position, targetPosition, Time.deltaTime * speed); //it will move from the current position to the target position and the time.deltaTime 
	}
}

Just re-write your code to the following:

using UnityEngine;

public class MovePlayer2 : MonoBehaviour
{

    public Vector2 targetPosition;

    private Rigidbody2D rb;

    [SerializeField]
    private float speed = 10;

    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        }
    }

    private void FixedUpdate()
    {
        if (targetPosition.magnitude > 0)
        {
            var position = Vector2.MoveTowards(transform.position, targetPosition, Time.deltaTime * speed);
            rb.MovePosition(position);
        }
    }   
}

You need to set the transform of the player’s to an empty gameObject

[SerializeField]
private Transform spawn;

void Start () {
   transform.position = spawn.position;
}