How to fix a situation that UNITY freezes as soon as you click on play?

I work on a game and every time I check that the software works properly.
Once I inserted a basic loop the software just froze, I deleted the loop it worked, and tried to change the loop but the game just freezes.
This is the code I would love to know what can be done about it.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControl : MonoBehaviour
{
//How fast the char will move on the screen
public int _playerMoveSpeed=5;
public Transform moveToPoint;
//The Speed stat of the char
private int _playerSpeed = 49;
//The Endurance stat of the char
private int _playerEndurance = 22;
//the amount of action points
public int _AP;
//the Amunt of Moves the char can do for one AP ( Moves Per Action Point)
public int _MPAP;

// Start is called before the first frame update
void Start()
{
    //we spetra the chiled from is father
    moveToPoint.parent = null;
    //we calculate the AP and MAAP
    _AP = _playerEndurance / 5;
    _MPAP = _playerSpeed / 15;
}

// Update is called once per frame
void Update()
{
   while (_AP > 0)
    {
        //we change the postion of our char to the postion of the move to point
        transform.position = Vector3.MoveTowards(transform.position, moveToPoint.position, _playerMoveSpeed * Time.deltaTime);

        // if we press all the way down on left ot right we going to somthing
        if (Vector3.Distance(transform.position, moveToPoint.position) <= .05f)
        {
            if (Mathf.Abs(Input.GetAxisRaw("Horizontal")) == 1)
            {
                moveToPoint.position += new Vector3(Input.GetAxisRaw("Horizontal"), 0, 0);
              //  _AP--;
            }
            else if (Mathf.Abs(Input.GetAxisRaw("Vertical")) == 1)
            {
                moveToPoint.position += new Vector3(0, 0, Input.GetAxisRaw("Vertical"));
               // _AP--;
            }
        }
    }
}

}
post Scriptum. I updated the software to the latest version

I was able to solve the problem I wrote instead of While, If.