I've had a similar sorting issue before. My workaround was to collect all the clicked objects on interact, then loop through them, and return the object with the highest z-sort value. If the sorting is being done by hierarchy, it might be easiest to automatically assign an increasing value on spawn to reference for interacts.