Why is Raycast not working properly?

I am making a game where the enemies patrol an area with waypoints. I want the player to be able to shoot enemies to remove their health and when the enemies health gets to zero it destroys the enemy. This works one the first enemy but after that it will show the ray hitting the wall or floor and ignores the enemy. In some instances it works for all the enemies but most of the time it only detects on enemy and stops working after that enemy is destroyed.

I fixed the problem by switching the enemies to is kinematic.