Hi, i made a custom character which uses :MoveTo() to follow the nearest player found.
The problem i have is that it doesn’t rotate the character while moving as you can see in this GIF: https://giphy.com/gifs/J2lyUSp5gPXu6YrxTC
AutoRotate is activated in the Humanoid
My follow script is:
local Config = require(script.Parent.Settings)
local NPC = script.Parent
local Human = NPC:FindFirstChildOfClass("Humanoid")
function GetTorso(Npcpos)
local distance = Config.MaxDistance
local PlrTors
for _,v in pairs(game.Players:GetPlayers()) do
if (not v.Character) then return end
local plrChr = v.Character
local plrTorso = plrChr:FindFirstChild("Torso")
local plrHuman = plrChr:FindFirstChild("Humanoid")
if (plrTorso) and (plrHuman) and (plrHuman.Health > 0) then
if (plrTorso.Position - Npcpos).magnitude < distance then
if ((plrTorso.Position - Npcpos).magnitude < 1.50) then return end
PlrTors = plrTorso
distance = (plrTorso.Position - Npcpos).magnitude
end
end
end
return PlrTors
end
while true do
wait(Config.Delay)
local PlrTorso = GetTorso(NPC:WaitForChild("HumanoidRootPart").Position)
if PlrTorso ~= nil then
Human:MoveTo(PlrTorso.Position,PlrTorso)
end
end
Thank you if you can help me with it