What do you want to achieve?
I want, that whenever the Player is in that red barrier, the NPC attacks them and once the player is out of the red barrier the NPC is standing still and shouldn’t get out of the barrier, if people it should stay in it’s original position.
What is the issue?
The issue is that I have no idea how I can raycast it and make the NPC have a pathfind.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have only looked up this video: Basic Raycasting in 13 Minutes: Roblox Studio Scripting - YouTube and this Advanced Roblox Scripting Tutorial #1 - Tools (Beginner to Pro 2019) - YouTube. Neither of them have really helped me, only the first one.
This may help: