Local variable isn't getting reset

                float moveDistance = 0;

                while ( Vector3.Distance(transform.position, player.position) > 2)
                {
                    transform.position = Vector3.MoveTowards(transform.position, player.position, moveDistance);

                    moveDistance += Time.deltaTime * followSpeed;
                   
                    yield return null;
                }

This works for a couple seconds, then it instantly teleports to the players position. I put log statements all over my code and it seems like moveDistance is going up to 9 and then stopping, then when this code happens again moveDistance starts at a normal number, then instantly goes to 9 the next frame. I’m really confused about this one.
8729286--1181061--upload_2023-1-13_17-5-50.png

This seems like it’s trying to “ease in” the speed it can move. I am assuming you’re inside a Coroutine here, but are you sure you only have one copy of the Coroutine running? It would be awfully easy to have multiple copies of the same Coroutine running, making movement debugging a nightmare. Moving important objects in non-predictable ways (follow the player, vs lift an elevator) should probably be done in the Update, not a Coroutine, for that reason.