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

[SOLVED] How do I stop a path? (Pathfinding Service)

Asked by 3 years ago
Edited 3 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

I've attempted moving the humanoid (:MoveTo()) to the humanoidrootpart, anchoring the HRP (humanoidrootpart) for a split second, and killing the humanoid doesn't work.

In general im trying to make the npc stop when killed.

pathfinding script:

local ps = game:GetService("PathfindingService")
local hum = script.Parent.Humanoid
local hrp = script.Parent.HumanoidRootPart
local path = ps:CreatePath()
--//
path:ComputeAsync(hrp.Position, game.Workspace.endpart.Position)
for _,waypoint in pairs(path:GetWaypoints()) do
    if waypoint.Action == Enum.PathWaypointAction.Jump then
        hum:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    if hum.Health > 0 then
        hum:MoveTo(waypoint.Position)
        hum.MoveToFinished:Wait(2)
    end 
end
--//
if hum.Health > 0 then
    hum:MoveTo(game.Workspace.endpart.Position)
end 
0
can you provide more code Pupppy44 671 — 3y

1 answer

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
3 years ago

Can you try this please?

local ps = game:GetService("PathfindingService")
local hum = script.Parent.Humanoid
local hrp = script.Parent.HumanoidRootPart
local path = ps:CreatePath()
--//
path:ComputeAsync(hrp.Position, game.Workspace.endpart.Position)
for _,waypoint in pairs(path:GetWaypoints()) do
    if waypoint.Action == Enum.PathWaypointAction.Jump then
        hum:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    if hum.Health > 0 then
        hum:MoveTo(waypoint.Position)
        hum.MoveToFinished:Wait(2)
    end 
end
--//
if hum.Health > 0 then
    hum:MoveTo(game.Workspace.endpart.Position)
end 

hum.Died:Connect(function()
    hum:MoveTo(hrp.Position)
end)
0
After a few weapon tests, I learned that it must have been the free model guns I was using for testing. I used the roblox linked sword and it worked, thanks! LonePioneer 2 — 3y
Ad

Answer this question