I made an NPC that moves to a specific part. It does work, but problem is that, when it moves, it faces another way instead of facing at the part. I tried making BodyGyros and setting it’s maxtorque to the max, but it did nothing really. Any help is appreciated!
Script inside NPC:
local npc = script.Parent
local humanoid = npc.Humanoid
local animator = humanoid.Animator
local animation = Instance.new("Animation")
local hrp = npc:WaitForChild("HumanoidRootPart")
local D1 = workspace.D1
local D2 = workspace.D2
local D3 = workspace.D3
local D4 = workspace.D4
local D5 = workspace.D5
local D6 = workspace.D6
local D7 = workspace.D7
local BodyGyro = Instance.new("BodyGyro", humanoid)
BodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
BodyGyro.CFrame = hrp.CFrame
animation.Parent = animator
animation.AnimationId = "rbxassetid://6085175514"
local RunService = game:GetService("RunService")
local animationplay = animator:LoadAnimation(animation)
animationplay.Looped = true
while true do
humanoid:MoveTo(D1.Position)
humanoid.MoveToFinished:Wait()
wait(1)
end
humanoid.Running:Connect(function(speed)
if speed > 0 then
animationplay:Play()
else
animationplay:Stop()
end
end)