Using only the code given, I can’t figure out what’s the issue. As your monster behaves strange, which it seems like it still chases you even without path being generated (I don’t see visual points appearing sometimes). Also I am unsure how you are implementing the loop. Generally, you shouldn’t use path:Run() in a loop with signals(also calling path:Run()) together, because when using a loop, signals are pointless as you are calling path:Run() in a certain interval anyways. Also how Trapped work is if the monster failed to reach the destination after a certain time, it fires. By calling path:Run() again, the trapped detection for the previous run will be canceled, making it unviable in this case if you are looping the path:Run().
local pathfindPosition = Vector3.new()
local Pathfinding = require(workspace.NoobPath)
local rake = workspace.Rig
local path = Pathfinding.Humanoid(rake,
{
AgentHeight = 4, -- 3
AgentRadius = 2, -- 2
AgentCanJump = true,
AgentCanClimb = true,
Costs = {
PathfindAvoid = 9999,
Truss = 1,
},
PathSettings = {
SupportPartialPath = true,
},
WaypointSpacing = 5.5 -- 10
}
)
path.Reached:Connect(function(Waypoint, IsPartial)
task.wait(.1)
path:Run(pathfindPosition)
end)
path.WaypointReached:Connect(function(Waypoint, NextWaypoint)
task.wait(0.1)
path:Run(pathfindPosition)
end)
path.Error:Connect(function(ErrorType : string)
warn(ErrorType)
task.wait(0.1)
path:Run(pathfindPosition)
end)
path.Trapped:Connect(function(TrapType : string)
print("Trapped")
if rake.Humanoid:GetState() ~= Enum.HumanoidStateType.Climbing then
path.Jump()
end
path:Run(pathfindPosition)
end)
path.Timeout = true
path.Speed = 16
path.Visualize = true
-- path.Precise = true -- Removed due to bad performance and limited usage, does nothing as of now
local first = true
-- Loop implementation A (Can use with signals)
while true do
task.wait(0.1)
pathfindPosition = workspace:WaitForChild("grewsxb4").PrimaryPart:GetPivot().Position
if first then
-- Run only once, then signals will handle the rest
path:Run(pathfindPosition)
end
first = false
end
-- Loop implementation B (Don't use with signals)
while true do
task.wait(0.1)
pathfindPosition = workspace:WaitForChild("grewsxb4").PrimaryPart:GetPivot().Position
path:Run(pathfindPosition)
end
I tested both Loop A and Loop B, no random jumping occurred.
Please provide me with more details.