ooh now that is very tough. I suppose the base idea is if the players delta distance from the npc is increasing drastically? and if the player is behind something (using raycast)? this would take a long time to code though.
Add a few parts and name them Trigger1, Trigger 2 etc
Make sure to make the Transparency of all Trigger parts to 1 and uncheck “Can Collide”
Add a “Sound” to your NPC and put the sound id in the “SoundID”
Add a script in your NPC
Find or make a script that makes your NPC play an animation & play the sound in it when a player is in one of the trigger areas/parts
if you also want the player to die you can also script that the players health becomes 0
There is no single tutorial that will help you with this, you would have to combine multiple tutorials.
But if you decompose what you want, you will need:
NPC with eyes
NPC shooting with guns
NPC pathfinding to players
Sound Detection
Search for tutorials or posts on the forum individually and combine them all into a single script or multiple.