Always remember, functions when called do not use the picked instance from the events that call them, you have to do the picking directly in the function itself.
It means that in your case, you could pass the enemies.UID value as parameter of the function and as sub-event/other condition from the function event, pick enemies by UID where the value is Function.param(0) (the first parameter passed).