https://imgur.com/a/soixPQa
You'll want to get the angle between the vector that represents the player's facing, and the vector between the player and the enemy. You can do this by normalising the two vectors, and dotting them. This will return a value in the range -1 to 1, where 1 represents perfect alignment, and -1 representing completely opposite directions.
https://chortle.ccsu.edu/VectorLessons/vch09/vch09_6.html
You can use this value in a if statement to get the monster to move conditionally (dot < 1?)
01 | local player = xxx.Character |
04 | local lookDir = player.Head.CFrame.lookVector |
05 | local toEnemy = player.PrimaryPart.CFrame.p - enemy.PrimaryPart.CFrame.p |
07 | local cosAng = lookDir.Unit:Dot(toEnemy.Unit) |
Untested, but that's the theory.