Enemy AI how to make my enemy look at the player

How to make my enemy look at the player

I want it went the player is for example about 250 pixels away from an enemies facing forward position,

When properly how I want it the goal is when player gets in the ray it will begin to take damage like the above photo it doesn’t really matter how fast since ill have heal mechanics here is my most recent try and for some reason it works when I’m on the right of it but not the left to clarify i did try ones like variable and flip horizontally for the thing the way its movement works is there’s arrows it touches it then flips other way

What is the actual result

(Sorry misunderstanding)
Ok, so if I get it correctly, your enemy box attacks your good box and the good box takes damage when it collides with that ray. And you want it to face towards the player when it is close enough, right?
If that is so, just test if the player box’s X position is greater than the enemy box’s X position. If true, flip it and move it to the right. Else, do the opposite.
And for it to not be interrupted by the other moving commands, add the ‘distance between two objects condition’. Invert it for the moving actions you have added.
Hope that helps.

Oopsie, I think I misunderstood your problem.
If it is the not taking damage when on left thing:
I’m pretty sure it’s because your both raycasts are at 180 degrees which is towards the RIGHT. At 0 degrees, it is at left. So maybe, if in the walking right condition, you just make that 180 into a 0, it will work? Hope, it works.