I couldn’t get the code to run correctly on Pico-8 0.2.6B.
Edit: Aha! I think it’s because the position of the player is stored in variables x and y and the position of each enemy is stored in variables X and Y (capitals), and the distinction gets lost when you copy and paste into Pico-8.