Npc not following another npc

local sets = script.Parent.Settings
local canJump = sets["Can the NPC jump when they hit a wall?"].Value
local distance = sets["Maximum Distance (In Studs)"].Value
local hrp = script.Parent:FindFirstChild("HumanoidRootPart")
local npcHumanoid = script.Parent:FindFirstChild("Humanoid")
local anim = script.idle
local track = script.Parent.Humanoid:WaitForChild("Animator"):LoadAnimation(anim)

local function Follow()
	local target = nil
	local shortestDistance = distance
	for _, model in ipairs(workspace:GetChildren()) do
		if model ~= script.Parent and model:FindFirstChild("Humanoid") and model:FindFirstChild("HumanoidRootPart") then
			print("FOUND")
			if model.Parent.Name == "camp2" then
				print("----what")
			local humanoid = model:WaitForChild("Humanoid")
			if humanoid.Health > 0 then
				print("NOTDEAD")
					local targetHRP = model:WaitForChild("HumanoidRootPart")
					local dist = (targetHRP.Position - hrp.Position).Magnitude
					print("Distance: ", dist)
					if dist <= shortestDistance then
						print("CLOSEST")
					shortestDistance = dist
					target = targetHRP
				end
			else
				print("o")
				end
			end
		end
	end

	local mim = 3
	if target then
		print("kill")
		npcHumanoid:MoveTo(target.Position)
		npcHumanoid.MoveToFinished:Wait()
		track:Play()
		script.Parent.Threat.Value = true
		script.Parent.bullie.Value = true
		local distanceToTarget = (target.Position - hrp.Position).Magnitude
		if distanceToTarget < mim then
			print("toclose")
			local directionAway = (hrp.Position - target.Position).Unit
			local newPosition = hrp.Position * directionAway * mim
			script.Parent.Humanoid.AutoRotate = false
			npcHumanoid:MoveTo(newPosition)
			wait(0.3)
			script.Parent.Humanoid.AutoRotate = true
		end
	else
		print("dead?") ---this line prints only when the npc is far or close to camp2 npc 
		script.Parent.Humanoid.AutoRotate = true
		track:Stop()
	end
end

while wait(0.1) do
	Follow()
	if canJump then
		script.Parent.JumpScript.Disabled = false
	end
end

so what the problem is script only prints dead? even if the npc is close to camp2 npc or far, it gives me no error or anything it just prints dead

can you send a video with the console open?

alirghty gimme a second (onetwo)

Is the npc actually inside camp2? Because you’re checking if the npc is inside that model. If its not that nothing will work.

I believe that :GetChildren() will only get the direct children of the instance you target, which is workspace, so if the NPC is foldered or in another model it won’t see it. Maybe try :GetDescendents() or using the folder or whatever area that the target NPCs are stored in?

nvm i got the solution i had to make workspace find the folder and make camp2:getchildren and find all models if their there
Uploading: wars - Made with Clipchamp.mp4…