Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why Isn't my Zombie NPC PathFindingService not working?

Asked by 2 years ago

So I made this script:

local NPC = script.Parent
local PathfindingService = game:GetService('PathfindingService')
local Players = game:GetService("Players")
local player

game.Players.PlayerAdded:Connect(function(client)
    player = client
end)

repeat wait() until player ~= nil

local path = PathfindingService:CreatePath()

path:ComputeAsync(NPC.Torso.Position, player.Character.PrimaryPart.Position)

if path.Status == Enum.PathStatus.Success then
    local Positions = path:GetWaypoints()

    for i,v in pairs(Positions) do
        local ball = Instance.new("Part", workspace)

        ball.Position = v.Position
        ball.Anchored = true
        ball.CanCollide = false
        ball.Size = Vector3.new(4,4,4)
        ball.Transparency = 0.5
        ball.Shape = Enum.PartType.Ball

        NPC.Humanoid:MoveTo(player.PrimaryPart.Position)
        NPC.Humanoid.MoveToFinished:Wait(2)
    end
end

As you can probably tell, this makes the NPC go towards the player but the problem Is where the NPC doesn't move towards the player

Answer this question