Why won't the zombie go towards the player?

I am making a zombie ai that attacks players in a 100 stud radius, but the zombie won’t go towards the player

robloxapp-20200910-1956180.wmv (1.5 MB)

The Script

while wait() do
	local humRootPart = FindTarget()
	if humRootPart then
		local zombiePath = PFS:CreatePath()
		zombiePath:ComputeAsync(zombieTorso.Position, humRootPart.Position)
		
		local waypoints = zombiePath:GetWaypoints()
		
		for i, v in pairs(waypoints) do
			
			local part = Instance.new("Part")
			part.Anchored = true
			part.CanCollide = false
			part.Size = Vector3.new(0.6,0.6,0.6)
			part.Position = v.Position + Vector3.new(0,2,0)
			part.Material = Enum.Material.Neon
			part.Shape = Enum.PartType.Ball
			part.Parent = workspace
			
			if waypoints.Action == Enum.PathWaypointAction.Jump then
				zombieHum:ChangeState(Enum.HumanoidStateType.Jumping)
			end
			humRootPart.Changed:Connect(function(Position)
				zombieHum:MoveTo(v.Position)
				zombieHum.MoveToFinished:Wait(1)
				zombieHum.WalkToPart = humRootPart
			end)
		end
	else
		wait(1)
		zombieHum:MoveTo(zombieTorso.Position + Vector3.new(math.random(-50,50), 0, math.random(-50,50)))
	end
end

Well, props for trying :slight_smile:

But that’s not how you want to go about it.

Will connect a Changed event to the root part every time the loop runs. Every one of those Changed events will then execute whenever any property of the part changes.

That doesn’t make much sense, and is ridiculously laggy as a bonus.

Why not read through this great article for a few ideas, especially the “Handling Blocked Paths” part. Seems like you can reuse the same path each calculation.