This is a link to my project as of writing
I'm attempting to create a shield mob that only attacks the robot if it is not behind a wall, and it does work, but only for and it doesn't rotate, either. If the robot leaves this region of the shield's Area2Ds, then it stops chasing it. Sorry, I'm sort of at a loss on where to go from here. Because looking at the script it looks like it should work normally, to me.
The reason is that with areas turned on, your raycast would often detect the SpellHolder of the Robot, so the target variable was looking for the Robot node, but the raycast's get_collider() function would often find the SpellHolder node instead, making the following condition fail:
if raycast.get_collider() == _target:
Because the SpellHolder covers the top part of the robot, the raycast could only hit the Robot's collision shape from below, which is why you observed it only working when the shield was below the Robot.