The cast a ray only triggers if there’s a test object in between the 2 locations. Since both events are sub events of it, the last event will never trigger. It should work if you remove the last line and add an action to set the value to 0 right before the ray cast.
Because you are casting a ray from enemy to player, and checking if the ray intersects the Obstacle object. It’s true if there is one in the way, and false if not.