So I have an NPC that's supposed to follow the player. I got it to do that, but it doesn't face the player when it moves and it's kind of just blank. Here's what it does I recycled this script from another npc that I made and it seems to work perfectly. I only switched models because it couldn't support animations. Zombie Any help with this? Here's the script
```
local function gethumanoids()
local humanpos = {}
for a, b in pairs(game.Workspace:GetChildren()) do
if b:FindFirstChild("Humanoid") and b ~= script.Parent then
local name = b.Name
if game.Players:FindFirstChild(name) then
table.insert(humanpos,(script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude)
end
end
end
table.sort(humanpos)
for a, b in pairs(humanpos) do
if a ~= 1 then
table.remove(humanpos.a)
end
end
for a, b in pairs(game.Workspace:GetChildren()) do
if b:FindFirstChild("Humanoid") and b ~= script.Parent then
local name = b.Name
if game.Players:FindFirstChild(name) then
if (script.Parent.HumanoidRootPart.Position - b.HumanoidRootPart.Position).magnitude == humanpos[1] then
return b
end
end
end
end
end
while true do
local path = game:GetService("PathfindingService"):CreatePath()
path:ComputeAsync(script.Parent.HumanoidRootPart.Position, gethumanoids().HumanoidRootPart.Position)
local points = path:GetWaypoints()
script.Parent.AttackingPlayer.Value = gethumanoids().Name
script.Parent.Parent.Points:ClearAllChildren()
for a, b in pairs(points) do
part = Instance.new("Part")
part.CanCollide = false
part.Size = Vector3.new(1,1,1)
part.Position = b.Position
part.Anchored = true
part.Transparency = 0
part.Parent = script.Parent.Parent.Points
end
if path.Status == Enum.PathStatus.Success then
for a, b in pairs(points) do
script.Parent.Humanoid:MoveTo(part.Position)
if b.Action == Enum.PathWaypointAction.Jump then
script.Parent.Humanoid.Jump = true
end
end
end
end```