I’m having a VERY annoying issue where even though it will detect and calculate paths for the positions I give it, it won’t calculate a path for the new position i send to it
what makes even LESS sense is the fact that it IS pathfinding for the other positions, it just doesn’t want to for this certain position I give it… It makes no sense, because as you can see it does indeed print out a Vector3 and sends a Vector3… The hell do I do here!?
EDIT: HELL I EVEN TRIED THIS AND IT STILL DIDN’T WORK
local function FollowPath(Destination)
-- Compute the path
local Success, ErrorMessage = pcall(function()
Path:ComputeAsync(model.Torso.Position, Destination)
end)
--CreateDebugPathParts()
if Success and Path.Status == Enum.PathStatus.Success then -- The AI can use this path/destion!
-- Get the path waypoints
Waypoints = Path:GetWaypoints()
-- Detect if path becomes blocked
BlockedConnection = Path.Blocked:Connect(function(BlockedWaypointIndex)
--print("Blocked")
-- Check if the obstacle is further down the path
if BlockedWaypointIndex >= NextWaypointIndex then
-- Stop detecting path blockage until path is re-computed
BlockedConnection:Disconnect()
-- Call function to re-compute new path
FollowPath(Destination)
end
end)
NextWaypointIndex = 2
-- Detect when movement to next waypoint is complete
while anti == true and wait(0.5) do
if NextWaypointIndex < #Waypoints and (model.Torso.Position - Destination).Magnitude > 10 then
-- Increase waypoint index and move to next waypoint
NextWaypointIndex += 1
humanoid:MoveTo(Waypoints[NextWaypointIndex].Position)
if Waypoints[NextWaypointIndex].Action == Enum.PathWaypointAction.Jump then
humanoid.Jump = true
end
elseif (model.Torso.Position - Destination).Magnitude <= 10 then
BlockedConnection:Disconnect()
anti = false
if PriorityDestination ~= nil and callingfunc == true then
PriorityDestination = nil
callingfunc = false
end
--print("Destination reached!")
else
BlockedConnection:Disconnect()
FollowPath(Destination)
end
--Initially move to second waypoint (first waypoint is path start; skip it)
humanoid:MoveTo(Waypoints[NextWaypointIndex].Position)
end
else
print("failed",ErrorMessage)
wait(1)
errors += 1
if errors < 3 then
FollowPath(Destination)
elseif errors >= 3 then
anti = false
errors = 0
PriorityDestination = nil
callingfunc = false
end
end
end