If it was me…
Everytime an enemy enters your collision radius, add it to an array of enemies (this should be easier if all of your enemies are subclasses of a main enemy blueprint). If the enemy leaves the area, remove its instance from the array. This means when there are no enemies in the collision radius the array is empty.
When you press your lock on button, cycle through the array and get the distance to each enemy, find out which distance is the smallest and set that as your lock on enemy.
After that you will have to update your players movement and animation. And any other things you want to change.
You will also have to set up an event for when a locked on enemy strays too far away, as they will be removed from the array automatically, however you will still be ‘locked onto’ them.
The reason your blueprint isnt working is probably to do with collision settings, make sure your cube is an ObjectType = Pawn and the capsule collision overlaps ‘Pawn’ class.