Well, this may mean that there is no enemy AI, in the index you get or your pawn is not spawned yet.
When you use beginplay you should use “Is Valid” node, to check if object exist to pass the logic you refer,
also you may add a bit delay after beginplay, to give those objects time to spawn and load, so their reference will be valid, once logic refers to them.