How do I compare locations and see which one is closer to a certain point?

Trying to have multiple AI pick a cover location, and if two AI pick the same cover location, whichever is closest to that location should head towards that location and the other should find a different cover Location. Heres a picture of the service I’m working on.

the basics of it is that you just need to take the target location and subtract from it the current location, then get the vector length. once you have the length of the vector you can use that as a comparison. for example in the picture below i took two locations and compared to see which was closer to the thirdpersoncharacter. this can also be done with an array of objects and a foreach loop. in the case of the array version you will need another variable to store the current shortest location (see picture 2 for example).