The problem is these while statements:
The function is running forever.
Instead you need to have startFollow add the sprite to a list and then in game.onUpdate do your follow logic.