This isn’t a code issue, this is a rigging issue. What you’ve posted is legacy code (not yours) responsible for having enemy NPCs follow the nearest Humanoid in the Workspace but it doesn’t have anything to do with character rotation. You need to resolve this by fixing your model to have the right rotation.
That being said, I didn’t download the video, since I prefer videos to be embedded onto the forum software itself if they exist, so this is an assumption I’m making based off of what the code is doing and what you’re reporting is happening.