Hi, my pathfinding script won’t work, and I can’t figure it out. Can anyone help?
code:
local pathfindingService = game:GetService("PathfindingService")
local humanoid = script.Parent:WaitForChild("Humanoid")
local humanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local destination = game.Workspace:WaitForChild("HealthPart").Position
local path = pathfindingService:CreatePath()
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
wait(1.5)
path:ComputeAsync(humanoidRootPart.Position, destination)
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
humanoid.MoveToFinished:Wait()
end
end)