I want to make it so that whenever a fox detects that its current movement settings literally cannot do anything to get to the player, it will change them.
Honestly, I just don’t know how this will work.
I tried thinking of a few ideas but they were quickly debunked…
– I just want to know how to detect when the game sees the pathfinder as impossible that can be told through script.
local PathFindingService = game:GetService("PathfindingService")
local FoxPathFinder = PathFindingService:CreatePath({
AgentRadius = 4.25,
AgentHeight = 0.5,
AgentCanJump = true
})
local WalkAnimation = script.Parent.Humanoid:LoadAnimation(script.WalkAnimation)
local IdleAnimmation = script.Parent.Humanoid:LoadAnimation(script.IdleAnimation)
local JumpAnimation = script.Parent.Humanoid:LoadAnimation(script.JumpAnimation)
local JumpDownAnimation = script.Parent.Humanoid:LoadAnimation(script.JumpDownAnimation)
local function RegularPath()
end
local function AgressivePath()
if script.Parent.Following.Value == true then
local StartPos = script.Parent.HumanoidRootPart.Position
local EndPos = game.Players:WaitForChild(script.Parent.Following.Target.Value).Character.HumanoidRootPart.Position
FoxPathFinder:ComputeAsync(StartPos, EndPos)
WalkAnimation:Play()
end
for index, waypoint in pairs(FoxPathFinder:GetWaypoints()) do
script.Parent.Humanoid:MoveTo(waypoint.Position)
local part = Instance.new("Part")
part.Position = waypoint.Position
part.Size = Vector3.new(0.5, 0.5, 0.5)
part.Color = Color3.new(1, 0, 1)
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
if waypoint.Action == Enum.PathWaypointAction.Jump then
if waypoint.Position.Y >= (script.Parent.HumanoidRootPart.Position.Y - 1) then
script.Parent.Humanoid.Jump = true
WalkAnimation:Stop()
JumpAnimation:Play()
end
if waypoint.Position.Y < script.Parent.HumanoidRootPart.Position.Y - 1 then
WalkAnimation:Stop()
JumpDownAnimation:Play()
end
end
if game.Players:WaitForChild(script.Parent.Following.Target.Value).Character.Humanoid.Health == 0 then
script.Parent.Following.Value = false
return
end
task.wait(0.1)
FoxPathFinder:ComputeAsync(script.Parent.HumanoidRootPart.Position, game.Players:WaitForChild(script.Parent.Following.Target.Value).Character.HumanoidRootPart.Position)
end
AgressivePath()
end
script.Parent.Following.Changed:Connect(AgressivePath)