Soldier AI is not taking damage

So, basically, i found a Solder AI, the problem is that the function of shooting is not working, here is the function:

function Shoot()
	--local flash = Instance.new("PointLight",barrel)
	--flash.Brightness = 0
	--game:GetService("Debris"):AddItem(flash,0.1)
	
	local bullet = Instance.new("Part",workspace)
	bullet.Size = Vector3.new(1,1,1)
	bullet.BrickColor = BrickColor.new("Gold")
	bullet.Velocity = myTorso.CFrame.lookVector * 400
	bullet.CFrame = barrel.CFrame
	bullet.CanCollide = false
	bullet.Touched:Connect(function(obj)
		if not obj:IsDescendantOf(script.Parent) then 
			local human = obj.Parent:FindFirstChild("Humanoid")
			if human then
				human:TakeDamage(45)
				human.Health = human.Health - 45
			end
			bullet:Destroy()
		end
	end)
	fireSound:Play()
	
	--game:GetService("Debris"):AddItem(bullet, 5)
end

By the way, if nothing is wrong with the function, here i can give you the entire script, which is a bit long:

Script
local myHuman = script.Parent:WaitForChild("Humanoid")
local myTorso = script.Parent:WaitForChild("Torso")
local rarm = script.Parent:WaitForChild("Right Arm")
local M4 = script.Parent:WaitForChild("M4")
local grip = M4:WaitForChild("BackGrip")
local barrel = M4:WaitForChild("Barrel")
local equipSound = barrel:WaitForChild("Equip")
local fireSound = barrel:WaitForChild("Fire")

local clone = script.Parent:Clone()

local aim = script.Parent:WaitForChild("Aim")
local aimAnimation = myHuman:LoadAnimation(aim)
aimAnimation.Priority = Enum.AnimationPriority.Action

function checkSight(target)
	local ray = Ray.new(myTorso.Position, (target.Position - myTorso.Position).Unit * 40)
	local part,position = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})
	if part then
		if part:IsDescendantOf(target.Parent) then
			if math.abs(position.y - myTorso.Position.Y) < 1 then
				return true
			end
		end
	end
	return false
end

function findTarget()
	local dist = 100
	local target = nil
	local potentialTargets = {}
	local seeTargets = {}
	for i,v in ipairs(workspace:GetChildren()) do
		local human = v:FindFirstChild("Humanoid")
		local torso = v:FindFirstChild("Torso") or v:FindFirstChild("HumanoidRootPart")
		if human and torso and v.Name ~= script.Parent.Name then
			if (myTorso.Position - torso.Position).magnitude < dist and human.Health > 0 then
				table.insert(potentialTargets,torso)
			end
		end
	end
	if #potentialTargets > 0 then
		for i,v in ipairs(potentialTargets) do
			if checkSight(v) then
				table.insert(seeTargets,v)
			end
		end
		if #seeTargets > 0 then
			for i,v in ipairs(seeTargets) do
				if (myTorso.Position - v.Position).magnitude < dist then
					target = v
					dist = (myTorso.Position - v.Position).magnitude
				end
			end
		else
			for i,v in ipairs(potentialTargets) do
				if (myTorso.Position - v.Position).magnitude < dist then
					target = v
					dist = (myTorso.Position - v.Position).magnitude
				end
			end
		end
	end
	return target 
end

function pathToLocation(target)
	local path = game:GetService("PathfindingService"):CreatePath()
	path:ComputeAsync(myTorso.Position, target.Position)
	local waypoints = path:GetWaypoints()
	
	for _,waypoint in ipairs(waypoints) do
		if waypoint.Action == Enum.PathWaypointAction.Jump then
			myHuman.Jump = true
		end
		myHuman:MoveTo(waypoint.Position)
		myHuman.MoveToFinished:Wait(2)
		if checkSight(target) then
			Attack(target)
			break
		end
	end
end

function walkRandom()
	local randX = math.random(-100,100)
	local randZ = math.random(-100,100)
	local goal = myTorso.Position + Vector3.new(randX, 0, randZ)
	local path = game:GetService("PathfindingService"):CreatePath()
	path:ComputeAsync(myTorso.Position, goal)
	local waypoints = path:GetWaypoints()
	
	if path.Status == Enum.PathStatus.Success then
		for _,waypoint in ipairs(waypoints) do
			if waypoint.Action == Enum.PathWaypointAction.Jump then
				myHuman.Jump = true
			end
			myHuman:MoveTo(waypoint.Position)
			myHuman.MoveToFinished:Wait(2)
		end
	else
		print("Path failed")
		wait(2)
	end
end

function Shoot()
	--local flash = Instance.new("PointLight",barrel)
	--flash.Brightness = 0
	--game:GetService("Debris"):AddItem(flash,0.1)
	
	local bullet = Instance.new("Part",workspace)
	bullet.Size = Vector3.new(1,1,1)
	bullet.BrickColor = BrickColor.new("Gold")
	bullet.Velocity = myTorso.CFrame.lookVector * 400
	bullet.CFrame = barrel.CFrame
	bullet.CanCollide = false
	bullet.Touched:Connect(function(obj)
		if not obj:IsDescendantOf(script.Parent) then 
			local human = obj.Parent:FindFirstChild("Humanoid")
			if human then
				human:TakeDamage(45)
				human.Health = human.Health - 45
			end
			bullet:Destroy()
		end
	end)
	fireSound:Play()
	
	--game:GetService("Debris"):AddItem(bullet, 5)
end

function Attack(target)
	local tWeld = Instance.new("Weld", script.Parent)
	tWeld.Part0 = grip
	tWeld.Part1 = rarm
	tWeld.C0 = CFrame.new(0.5,-0.5,0.9) * CFrame.Angles(math.rad(-90),math.rad(65),math.rad(-115))
	
	equipSound:Play()
	
	repeat 
		
		aimAnimation:Play()
		
		local forwardVector = (target.Position - myTorso.Position).Unit
		local upVector = Vector3.new(0,1,0)
		local rightVector = forwardVector:Cross(upVector)
		
		for i = 0, 1, 0.1 do 
			wait()
			myTorso.CFrame = myTorso.CFrame:lerp(CFrame.fromMatrix(myTorso.Position, rightVector, upVector),i)
		end
		
		Shoot()
		
		if (myTorso.Position - target.Position).magnitude < 15 then
			myHuman.AutoRotate = false
			local c = myTorso.CFrame * CFrame.new(0,0,5)
			myHuman:MoveTo(c.p)
		elseif (myTorso.Position - target.Position).magnitude > 30 then
			myHuman.AutoRotate = false
			local c = myTorso.CFrame * CFrame.new(0,0,-5)
			myHuman:MoveTo(c.p)
		end
		
		wait(0.3)
		myHuman.AutoRotate = true
	until checkSight(target) == false or target == nil or target.Parent.Humanoid.Health < 1 
	
	game:GetService("Debris"):AddItem(tWeld,0)
	equipSound:Play()
end

function main()
	local target = findTarget()
	if target then
		pathToLocation(target)
	else
		walkRandom(target)
	end
end

function Died()
	wait(5)
	clone.Parent = workspace
	game:GetService("Debris"):AddItem(script.Parent,0)
end

myHuman.Died:Connect(Died)

while wait(1) do
	main()
end

Thanks for reading.