You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? To cancel path find and npc to stop walking.
What solutions have you tried so far? Did you look for solutions on the Developer Hub? Most of them made me confused! I couldn’t understand any of them!
im new to scripting. I tried this so far. WalkTo(script.Parent.HumanoidRootPart)
Here is my script so far.
function WalkTo(Position)
local pathfindingService = game:GetService("PathfindingService")
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("UpperTorso")
local path = pathfindingService:CreatePath()
path:ComputeAsync(body.Position, Position.Position)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
Humanoid:MoveTo(Position.Position)
Humanoid.MoveToFinished:Wait()
end
for k, waypoint in pairs(waypoints) do
if not script.Parent.VALUES.Busy_01.Value then
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
else
break
end
script.Parent.Humanoid:MoveTo(script.Parent.HumanoidRootPart.Position)
end
local stop = false
function WalkTo(Position)
local pathfindingService = game:GetService("PathfindingService")
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("UpperTorso")
local path = pathfindingService:CreatePath()
path:ComputeAsync(body.Position, Position.Position)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
if stop then return end
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
Humanoid:MoveTo(Position.Position)
Humanoid.MoveToFinished:Wait()
end
function Cancel()
stop = true
end
local stop = false
function WalkTo(Position)
stop = false
local pathfindingService = game:GetService("PathfindingService")
local body = script.Parent:FindFirstChild("HumanoidRootPart") or script.Parent:FindFirstChild("UpperTorso")
local path = pathfindingService:CreatePath()
path:ComputeAsync(body.Position, Position.Position)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
if stop then return end
Humanoid:MoveTo(waypoint.Position)
Humanoid.MoveToFinished:Wait()
end
Humanoid:MoveTo(Position.Position)
Humanoid.MoveToFinished:Wait()
end
function Cancel()
stop = true
end