There’s a few ways you can do this.
The fastest/easiest (but not necessarily best.) way is to cast your trace hit (which tells the character where to move) to an enemy. If it fails, do what it does now.
It if succeeds, get distance between player and hit target. If >200 tell player to move to hit actor. Else play attack animation and do attack sequence that does damage or whatever.