Enemy follow script

hi I present myself with a rather strange problem.
I made a script for an enemy to follow people. but the thing is, he walks sideways.

robloxapp-20210207-1628337.wmv (2.4 MB)

as you can see, it does not look aesthetically.

here is script

if anyone could help, I would be very grateful.

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.

1 Like

Unrelated to the question, but I’d recommend using a table.sort function instead of that.

ok sorry for saying it’s mine. I’ll see what I can do

i fixed it. The problem was i wrong set the front surface