What I intend for this code is for the pathfinding to go away from the chosen position, and it does work, to an extent. However, it seems that after the original position is calculated, the pathfinding attempts to get closer instead of going away?
Here is my code:
while status.value == "Run" do -- Run away from this position
local path = PathfindingService:CreatePath({AgentRadius = 5})
path.Blocked:Connect(function()
print("Break!")
breakPath = true
end)
path:ComputeAsync(dummy.Torso.Position, -finish.Position)
if path.Status == Enum.PathStatus.Success then
breakPath = false
local waypoints = path:GetWaypoints()
local wastedTime = 0
for _, waypoint in pairs(waypoints) do
repeat
local distance =
(dummy.Torso.Position + waypoint.Position).magnitude
if(waypoint.Action == Enum.PathWaypointAction.Jump) then
humaoid.Jump = true
end
wastedTime = wastedTime + 1
if breakPath == true then break end
humaoid:MoveTo(waypoint.Position)
wait()
until (dummy.Torso.Position - waypoint.Position).magnitude > 1
or breakPath == true or wastedTime >= 75
end
end
end
Here's a gif of what I'm trying to say
Any help would be appreciated.
