AI Following Script Doesn't Work

Hello Users, I am making this AI follow script to follow the player. While it does work. The rotation of the NPC itself isn’t correct.

It is supposed to be standing like this.
image

But when I launch the game it seems to move torwards the player sideways.

An help/suggestions??

I would confirm this that you used :MoveTo function only, which will like go to the direction of player without detecting any blocks. In order to fix this, you need to use pathfinding service

I might be wrong tho with expectations. But yeah by in the video, it shows like the npc going to the player without handling blocked paths.

Yeah I used the MoveTo,

local Distance = 100
local SCP999 = script.Parent


function getNearestPlayer(Player)
	local hum = Player.Character:WaitForChild("Humanoid")
	local humroot = Player.Character:WaitForChild("HumanoidRootPart")	
	if (SCP999:WaitForChild("HumanoidRootPart").Position - humroot.Position).Magnitude < Distance then
		SCP999:WaitForChild("Humanoid"):MoveTo(humroot.Position)
	end
end

while wait() do
	for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
		getNearestPlayer(plr)
	end
end

But Im more focused on how to get the AI standing straight up.

Try checking the orientation of the PrimaryPart. Make sure the front is facing the way it should be.

Think I found the problem.
Their appears to be an invisible block when I run the game.
image

It doesn’t show it on studio though.
image

Nevermind It’s still doing it.

Try to set a PrimaryPart inside the model to see if it fix the issue

image
Has been on a primaryPart

Change the orientation of the HumanoidRootPart