How I would tackle this depends a bit on how you want to implement this condition in your game. I would do the following to loop through the instances of object Object, comparing the distance to each with a max search distance:
var MyUID = Player.uid [the uid of the object you wish to ignore from this search]
var OtherUID = -1
var ObjectiveX, var ObjectiveY [set these to the x and y coordinates of the center of your search]
var LocalDistance = 10000 [where this value is the max range of your search]
C: For Each Object
C: Object.uid != MyUID
var tempDistance = distance(Object.x, Object.y, ObjectiveX, ObjectiveY)
C: If tempDistance < LocalDistance
-- A OtherUID = Object.uid
-- A LocalDistance = tempDistance
If OtherUID > -1 then that is the UID of the closest Object within the search range you specified (-1 = none found). You could also filter the objects for Is On Screen, or you could use a large invisible collision object to reduce the number of Object instances you loop through by first testing for Is Overlapping (only if your layout is huge with many Object instances, otherwise I wouldn't bother).