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

Im am trying to make a npc move with pathfinding service, but it wont move, any know why?

Asked by 3 years ago



local dummy = game.Workspace.Dummy:WaitForChild("HumanoidRootPart") local human = dummy:WaitForChild("Humanoid") local point = game.Workspace.Part1 local PathfindingService = game:GetService("PathfindingService") local path = PathfindingService:CreatePath() path:ComputeAsync(dummy.HumanoidRootPart.Position, point.Position) local waypoints = path:GetWaypoints() for _, waypoint in pairs(waypoints) do local part = Instance.new("Part") part.Shape = "Ball" part.Material = "Neon" part.Size = Vector3.new(0.6, 0.6, 0.6) part.Position = waypoint.Position part.Anchored = true part.CanCollide = false part.Parent = game.Workspace human:MoveTo(waypoint.Position) human.MoveToFinished:Wait() end
0
is your dummy anchored? there is no issue in the script, so you might wanna check that. FirewolfYT_751 223 — 3y
0
its unanchored ABCTrainerDude 12 — 3y
0
It's something with the dummy, I tested it and it worked NotMiskie 78 — 3y
0
ok ABCTrainerDude 12 — 3y

1 answer

Log in to vote
0
Answered by
QWJKZXF 88
3 years ago

The pathfinding service only works if the humanoid has somewhere to move to, and it seems like you tell the humanoid to move to what position, therefore the script doesn't know what the destination is. After your in pairs loop, add a human:MoveTo(point.Position) and it should work.

local dummy = game.Workspace.Dummy:WaitForChild("HumanoidRootPart")
local human = dummy:WaitForChild("Humanoid")
local point = game.Workspace.Part1
local PathfindingService = game:GetService("PathfindingService")
local path = PathfindingService:CreatePath()
path:ComputeAsync(dummy.HumanoidRootPart.Position, point.Position)
local waypoints = path:GetWaypoints()

for _, waypoint in pairs(waypoints) do
    local part = Instance.new("Part")
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = waypoint.Position
    part.Anchored = true
    part.CanCollide = false
    part.Parent = game.Workspace

    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait()
end

human:MoveTo(point.Position)
0
Ok, thanks! ABCTrainerDude 12 — 3y
Ad

Answer this question