Ok So I am trying to update my chase script for my zombies from the deprecated and older system of GetPointCoordinates() to GetWaypoints(). Right now my script works but as you can see in the script I have to tell NPC's to jump and to be honest it is not the best pathfinding script. If anyone has any suggestions, a better NEW pathfinding script or can help me re-code this I would be very grateful for the help. Thanks in advance.

workspace:WaitForChild("Wave0")
local p=game:GetService("PathfindingService")

p.EmptyCutoff=0.024


			
function addz(v)
	spawn(function()
		v:WaitForChild("Humanoid").WalkSpeed=16
		local parts={}
		local target=v.Head
				v.Humanoid.Died:connect(function()wait(5)v:Destroy().Parent=workspace.Wave0 end)

		while wait()do
			if v.Humanoid.Health==0 then break end
			
			if target==v.Head or not target:IsDescendantOf(workspace)then
				local r={}
				for _,v in pairs(game.Players:GetPlayers())do
					pcall(function()
						r[#r+1]=v.Character.Head
					end)
				end
				target=#r>0 and r[math.random(1,#r)]or target
			end
			for _,v in pairs(parts)do v:health(-20)end parts={}
			local path=p:FindPathAsync(v.Head.Position,target.Position)
			if(v.Head.Position-target.Position).magnitude<3 and target~=v.Head then
				
	
			end
			local points=path:GetPointCoordinates()
			if #points>1 then
				for i=2,5 do
					local part,point=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i)],Vector3.new(0,0.5,0)))
					local part,point2=workspace:FindPartOnRay(Ray.new(points[math.min(#points,i+1)],Vector3.new(0,0.5,0)))
					local count=0
					while math.min((point2-v.Head.Position).magnitude,(point*Vector3.new(1,0,1)-v.Head.Position*Vector3.new(1,0,1)).magnitude)>3 and count<50 do
						count=count+1
						v.Humanoid:MoveTo(point2)
						if workspace:FindPartOnRay(Ray.new(v.Head.Position,CFrame.new(v.Head.Position*Vector3.new(1,0,1),point2*Vector3.new(1,0,1)).lookVector*4))then
							v.Humanoid:MoveTo(point)
						end
						if workspace:FindPartOnRay(Ray.new(v.Head.Position,CFrame.new(v.Head.Position*Vector3.new(1,0,1),point*Vector3.new(1,0,1)).lookVector*3))then
							v.Humanoid.Jump=true
						
						end
						wait()
					end
				end
			else
				v.Humanoid:MoveTo(target.Position)
				if target.Position.Y>=v.Humanoid.Torso.Position.Y+1 then
					v.Humanoid.Jump=true
				end
			end
		end
	end)
end
workspace.Wave0.ChildAdded:connect(addz)
for _,v in pairs(workspace.Wave0:GetChildren())do
	wait(.1)
	 addz(v)
 end