Npc doesn't move with pathfinding(Solved)

Our npc’s doesn’t move. I leave a video here. At first, it’s just worked I don’t know why. But at second time you can see problem. To simplify problem I delete all accessories and body parts except torso and legs. Still not moving. Then I delete legs and only torso left and it starts moving.

parts aren’t anchored. Is it something related with motor6d settings?

not sure if matters and think its obvious but i give coordinates of related ores in the wall. This is the code

local path = PathfindingService:CreatePath({
	AgentRadius = 1,
	AgentHeight = 5,
	AgentCanJump = true,
})

path:ComputeAsync(rootPart.Position, targetPos)

if path.Status == Enum.PathStatus.Success then
	local waypoints = path:GetWaypoints()

	for i, waypoint in ipairs(waypoints) do
		local marker = Instance.new("Part")
		marker.Size = Vector3.new(0.5, 0.5, 0.5)
		marker.Shape = Enum.PartType.Ball
		marker.Material = Enum.Material.Neon
		marker.Color = Color3.fromRGB(0, 255, 0)
		marker.Anchored = true
		marker.CanCollide = false
		marker.CFrame = CFrame.new(waypoint.Position)
		marker.Parent = workspace

		if i > 1 then
			local prevPos = waypoints[i - 1].Position
			local distance = (prevPos - waypoint.Position).Magnitude
			local line = Instance.new("Part")
			line.Anchored = true
			line.CanCollide = false
			line.Material = Enum.Material.Neon
			line.Color = Color3.fromRGB(255, 255, 0)
			line.Size = Vector3.new(0.1, 0.1, distance)
			line.CFrame = CFrame.new(prevPos:Lerp(waypoint.Position, 0.5), waypoint.Position)
			line.Parent = workspace
		end
	end

	-- 🔹 NPC hareketi
	for _, waypoint in ipairs(waypoints) do
		humanoid:MoveTo(waypoint.Position)
		if waypoint.Action == Enum.PathWaypointAction.Jump then
			humanoid.Jump = true
		end
		humanoid.MoveToFinished:Wait()
		print("waypoint check")
	end
else
	warn("No way!")
	humanoid:MoveTo(targetPos)
end
1 Like

try anchor the npc, and then unanchor the npc again

tried now but only moves very small distance

sorry for late reply, try setting the SetNetworkOwnership to nil

tried that now but still doesn’t work. Seems like legs stuck inside ground i guess. is there a method to do except hips height?

Hey! Your pathfinding code looks fine the problem isn’t in the script but in your NPC’s rig.
If it only moves when you delete the legs, that means the Motor6D joints between the torso and legs are broken or missing.

Make sure your NPC is set up like a normal character:

  • Has a HumanoidRootPart (set as the Humanoid’s RootPart).
  • All body parts connected with Motor6D, not Welds.
  • Nothing is anchored.

Once the rig is fixed, your pathfinding movement should work normally again

thanks for response
I fixed it. There were two problems in my case actually
our modeler made some parts collidable so they collide and behave awkwardly.
To fix this I only made humanoidrootpart were collidable but in this case its half buried moving.

So i did some research and find this formula.
Corrected names so now humanoid can correctly calculate body height of our npcs. it moves great now!

1 Like