I do not know what I did wrong.
Read the error message. Q: What happens if there’s no enemy present? A: The code fails because “Target is null.” There is no target (enemy) so code returns null. What did you write before,
hero.pickUpFlag(flag)? You checked to see if there was a flag. If this condition exists, then do something. If you just write, then do something, and there is no code to check the condition, if the conditions don’t support it, it fails.
Is there always an enemy?
already figured it out
Maybe could you try thinking about your problems for a bit longer if you can figure it out so soon after trying it.