LineTraceObject for AI Attacking?

Can the AI use LineTracebyObject to attack the enemy player?

I been trying to do this but its been leading to the game crashing, is there a way to do this?

The big reason why i want this is because to allow the AI to only attack when the Line hits the character my current situation the AI can
attack from any side even the back.

You would have better luck using a Pawn Sensing Component for this and lowering the peripheral cone vision.