#Path always being successful even when it shouldn't be.

1 messages · Page 1 of 1 (latest)

lapis tartan
#

It's trying to walk through a wall and I don't know what broke for it to do this. A side issue is that whenever I try and change the direction it's facing to the waypoint it is lagging a lot.

#

local SCP = script.Parent
local PrimaryPart = SCP.PrimaryPart
local PathFindingService = game:GetService("PathfindingService")
local Path = PathFindingService:CreatePath({

AgentRadius = 2,
AgentHeight = 0.64,
WaypointSpacing = 1,
costs = {
AvoidWallZone = math.huge

}

})

wait(3)

while true do
wait()
local TargetName = SCP:GetAttribute("ClosestPlayerName")
local Distance = SCP:GetAttribute("DistanceToTarget")
local Target = game.Workspace:FindFirstChild(TargetName).HumanoidRootPart

if Distance < 20 then
    if Distance > 6 then    
            Path:ComputeAsync(SCP.PrimaryPart.Position, Target.Position)
            local waypoints = Path:GetWaypoints()
            for i, waypoint in waypoints do

                local p = Instance.new("Part", workspace)
                p.Position = waypoint.Position
                p.Anchored = true
                p.Material = Enum.Material.Neon
                p.CanCollide = false
                p.Size = Vector3.new(1,1,1)
            end
        
            for i, waypoint in waypoints do
                wait()
                SCP.Humanoid:MoveTo(waypoint.Position)
            end                
            
            if Path.Status == Enum.PathStatus.Success then
                for i, wapoint in waypoints do
                    SCP.Humanoid:MoveTo(wapoint.Position)
                    SCP.PrimaryPart.CFrame = CFrame.lookAt(SCP.PrimaryPart.Position, Target.Position)
                end
            else
                warn("Path not possible")
            end

    end
end

end

viscid oyster
#

theres a few other issues tho, the lag is probably because ur spawning those neon parts very frequently,

also, why are you calling MoveTo() in 2 diff loops

            for i, waypoint in waypoints do
                wait()
                SCP.Humanoid:MoveTo(waypoint.Position)
            end
            if Path.Status == Enum.PathStatus.Success then
                for i, wapoint in waypoints do
                    SCP.Humanoid:MoveTo(wapoint.Position)
                    SCP.PrimaryPart.CFrame = CFrame.lookAt(SCP.PrimaryPart.Position, Target.Position)
                end

youre moving it the first time for each waypoint
and then youre moving it again if the path is a success

old birchBOT
#

studio** You are now Level 1! **studio

viscid oyster
#

cc @lapis tartan

lapis tartan
#

Ah, I see.