NPC aiming at zombies?

I’m having trouble making this npc aim towards the nearest zombie, as well as making it shoot at it, so far it just shoots in one area, I have no clue on how I should do this, and tried to search up tutorials on youtube. Script

local tool = script.Parent
local range = script.Parent.Parent.Stats.range.Value
local damage = script.Parent.Parent.Stats.damage
local Bullet = Instance.new("Part", workspace)
local ShootSpeed = script.Parent.Parent.Stats.shootspeed.Value
local Sound = script.Parent.Sound
function shoot()
	Bullet.Transparency = 0
	Bullet.CanCollide = true
	Bullet.Position = script.Parent.Handle.Position
	Bullet.Anchored = true
	Bullet.Name = "Police1Bullet"
	Bullet.BrickColor = BrickColor.new("New Yeller")
	Bullet.TopSurface = Enum.SurfaceType.Smooth
	Bullet.BottomSurface = Enum.SurfaceType.Smooth
	Bullet.Size = Vector3.new(0.3,0.1,0.1)
	Bullet.Orientation = Vector3.new(0, 90, 0)
	Bullet.Parent = tool
	for yes = 1,range do
		wait(0.01)
		Bullet.Position = Bullet.Position + Vector3.new(0,0,-1)
	end
	Bullet.Transparency = 1
	Bullet.CanCollide = false
end
while wait(ShootSpeed) do
	Sound:Play()
	shoot()
end

If it matters, script for zombies:

FastZombie = script.Parent.Humanoid
local Health = script.Parent.Values.Health.Value
FastZombie.WalkSpeed = script.Parent.Values.Speed.Value
function onTouched(hit)
	if (hit.Name == "Police1Bullet") then
		Health = Health - 1
		wait(0.1)
		if Health < 1 then
			script.Parent:Destroy()
		 end
	end
end

connection = FastZombie.Touched:connect(onTouched)
local physicsService = game:GetService("PhysicsService")
physicsService:CreateCollisionGroup("Zombies")
physicsService:CollisionGroupSetCollidable("Zombies", "Zombies", false)
local Zombie = game.ReplicatedStorage.Enemies.Zombie
local FastZombie = game.ReplicatedStorage.Enemies["Fast Zombie"]
local BigZombie = game.ReplicatedStorage.Enemies["Big Zombie"]
local MarbleZombieBoss = game.ReplicatedStorage.Enemies["Marble Zombie"]
local Part1 = game.Workspace.Part1
local Part2= game.Workspace.Part2
local Part3 = game.Workspace.Part3
local Part4 = game.Workspace.Part4
local dead = false
local HealthEvent = game.ReplicatedStorage.Events.HealthEvent
function wave(zombieType, numberOfZombies)
	for index = 1, numberOfZombies do
		spawn(function()
			local ZombieClone = zombieType:Clone()
			for _, part in ipairs(ZombieClone:GetDescendants()) do
				if part:IsA("BasePart") then
					physicsService:SetPartCollisionGroup(part, "Zombies")
				end
			end
			ZombieClone:SetPrimaryPartCFrame(CFrame.new(-108.33, 0.5, -27.21))
			ZombieClone.Parent = workspace
			wait(1)
			ZombieClone.Humanoid:MoveTo(Part1.Position)
			ZombieClone.Humanoid.MoveToFinished:Wait()
			ZombieClone.Humanoid:MoveTo(Part2.Position)
			ZombieClone.Humanoid.MoveToFinished:Wait()
			ZombieClone.Humanoid:MoveTo(Part3.Position)
			ZombieClone.Humanoid.MoveToFinished:Wait()
			ZombieClone.Humanoid:MoveTo(Part4.Position)
			ZombieClone.Humanoid.MoveToFinished:Wait()
			ZombieClone.Humanoid:Destroy()
			wait(1)
			ZombieClone:Destroy()
		end)
		wait(.10) -- Delay Inbetween Spawning Zombies (Remove if you want)
	end
end
wave(FastZombie, 5)
wave(Zombie, 5)
wave(BigZombie,2)
wave (MarbleZombieBoss, 1)

First, I’m concerned that your bullets aren’t going to aim in the direction the NPC is facing based on the shoot function. You should look into either Raycasting and switching between world and object space with CFrames (Understanding CFrames, CFrame reference).

Moving on to aiming at the nearest zombie. I’d say that for each frame (or another time increment), you’d want to figure out how far away each zombie is and then pick the closest to aim at. I don’t see a clear way to identify zombies in your current code, but let’s say you keep them all in a table that looks like zombies = {Zombie1, Zombie2, ...}.
At each time increment (either use RunService.Heartbeat or a while loop), you would cycle through each zombie in the table (we’ll also say that you’ve defined a variable npc for your NPC model):

local zombieMinDistance = math.huge
local currentClosest = nil
for _,zombie in pairs(zombies) do
    if zombie then
        local zombiePosition = zombie.HumanoidRootPart.Position
        local distanceFromNPC = (zombiePosition - npc.HumanoidRootPart.Position).Magnitude
        if distanceFromNPC < zombieMinDistance then
            zombieMinDistance = distanceFromNPC
            currentClosest = zombie
        end
    end
end

At the end of this, currentClosest should be the zombie to aim at. I’m guessing you have a system for aiming and turning. I don’t know enough about manipulating humanoids to be of much help there, but this tread might be helpful: Making an NPC look at your character.

Once you have a zombie you’re aiming at, you should be ready to shoot, rinse, and repeat.