[Right Click to Necromance] How I do the run system, for only one character? (FOR 2D RPG GAME)

Hello, i need help to make the run system of the game Right Click To Necromance, I creating a 2D Panoramic RPG Game. The system is : When the player is clicking, the character follow the cursor in speed of character, and when stops clicking, the character stop where he is. Sorry for my English, I’m brazilian. Thanks if you helped me!

So, what you need to do:

  1. Find the coordinate of where you clicked.

  2. Send the player there, while the button is held down.

    public class MovementScript : MonoBehaviour {

     public Transform player;
    
     // How many units you want your player to move per second.
     public float playerSpeed;
    
     // World coordinates under the mouse
     Vector3 targetPosition;
    
     void Update(){
     	// Get these world coordinates
     	// Input.mousePosition returns a position of the mouse on the screen.
     	// Camera.main.ScreenToWorldPoint uses the position of the mouse to convert it to a world position.
     	targetPosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
    
     	// If the player is holding down the left mouse button ( GetMouseButton(0) is the left mouse button)
     	if (Input.GetMouseButton (0)) {
     		// Get the movement direction
     		Vector3 direction = targetPosition - player.position;
     		// Normalize it (make the vector magnitude be 1)
     		Vector3 normalizedDirection = direction.normalized;
     		// Add the direction to the current player position, with playerSpeed
     		player.position += normalizedDirection * playerSpeed * Time.deltaTime;
     	}
     }
    

    }

Ohhh, thanks man you helped me a lot!!