PathfindingService can’t find the chest when the chest is right next to it, just around the wall. Why is this and how do I fix it? The chest is a part and the position is correct.
Script:
local PathfindingService = game:GetService("PathfindingService")
local Humanoid = script.Parent.Humanoid
local Root = script.Parent:FindFirstChild("HumanoidRootPart")
local goal = game.Workspace.Ignore.Items.CHEST.Position
local pathParams = {
AgentRadius = 2,
AgentHeight = 5,
AgentCanJump = true,
}
local path = PathfindingService:CreatePath(pathParams)
function compute()
goal = game.Workspace.Ignore.Items.CHEST.Position
path:ComputeAsync(Root.Position, goal)
if path.Status == Enum.PathStatus.Success then
print("Yay")
else
print("Nay")
wait(1)
return compute()
end
local waypoints = path:GetWaypoints()
for i, waypoint in ipairs(waypoints) do
print("Pathing")
Humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid.MoveToFinished:Wait()
end
wait(1)
return compute()
end
compute()