Help with destroying a sprite from an array

i have an array with 3 sprites the 3 sprites all chase the player, z places the 3 sprites in random places, x starts and stops there chasing, and c (uses a keybored compatable extension) destroys the closests sprite, but i cant get it to target the closest sprite, also i want to be able to limit tne range of destroying the sprite

heres the link https://arcade.makecode.com/S02703-58638-26883-01322

Screenshot 2026-04-16 8.35.01 PMsomething like this should work