If Statement for Hit

What is the if statement and the setup for it if necessary for the object to detect a hit from a raycast? This is for like an enemy to see if it got hit by a ray cast from a gun.

do you want to detect the hit in the object that casted the ray or in the object that was hit?

The object that was hit please

Sorry, I’ll be more specific. The Script for this will be on a enemy. The enemy will be the one seeing if it is hit by the raycast from the gun.