There is never a path when pathfinding even if there should be one

I wanted to create a pathfinding monster that could teleport near players but they could not see him.
It never worked because it never found a path. However the position to where he should teleport should return a path. Anyone knows why?

I tried to change the find path part, but it doesn’t seem to work and I added a part that needed to spawn at the position, it should have computed a path but didn’t work

Position = ChosenPlayer.Character.HumanoidRootPart.Position + Vector3.new(math.random(-50,50),math.random(-10,10),math.random(-50,50))
local rayCastParams = RaycastParams.new()
rayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
rayCastParams.FilterDescendantsInstances = {game.Teams.Playing,killer}
local RayCast = game.Workspace:Raycast(Position,Vector3.new(0,-20,0),rayCastParams)
if RayCast and RayCast.Position then
	print(RayCast.Position)
	local truePosition = RayCast.Position+Vector3.new(0,killer.HumanoidRootPart.Size.Y,0)
	local See = seeTarget(ChosenPlayer.Character,true,truePosition)
	
	local part = Instance.new("Part",workspace)
	part.Position = truePosition
	part.Anchored = true
	part.Size = Vector3.new(1,1,1)--delete that section later
	
	print(truePosition)
				
	local success, errorMessage = pcall(function()
		pathSettings:ComputeAsync(part.Position,ChosenPlayer.Character.Head.Position)--problem seems to be here
	end)
				
	if success and pathSettings.Status == Enum.PathStatus.Success and See == false then
		killer:MoveTo(truePosition)
	else
		if See then
			warn("Could See the player")
		else
			warn("Could not compute the path :", pathSettings.Status, errorMessage)
		end
		ChoosePosition()--recalls the function
	end
end

Fixed it myself so, it happened because I had a humanoid not parented to anything :grin:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.