Damage stops working after a couple of seconds

hello, i need help with something, im making a barrage attack and the damage stops working after a couple of seconds, can you guys help me

this is the damage code.

game:GetService("ReplicatedStorage").Remotes.GumGatling.OnServerEvent:Connect(function(player)
	local hitbox = Instance.new("Part")
	local DB = false
	hitbox.Size = Vector3.new(6.5,6.5,5)
	hitbox.Anchored = true
	hitbox.CanCollide = false
	hitbox.Parent = workspace
	hitbox.Transparency = 1
	hitbox.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if not hit:IsDescendantOf(player.Character) then 
				if DB == false then
					DB = true
					hit.Parent.Humanoid.Health -= 5
					wait(.2)	
					DB = false
				end
				return end					
		end
	end)	
	game:GetService("ReplicatedStorage").Remotes.StopGumGatling.OnServerEvent:Connect(function()
		hitbox:Destroy()
	end)
	while true do 
		wait() 
		hitbox.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2.8)
	end
end)

this is the full code.

game:GetService("ReplicatedStorage").Remotes.GumGatling.OnServerEvent:Connect(function(player,mousePos)
	local Gatling
	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://10222283865"
	sound.Volume = 1
	sound.Looped = true
	sound.Parent = player.Character.HumanoidRootPart
	sound:Play()
	Gatling = true
	game:GetService("ReplicatedStorage").Remotes.StopGumGatling.OnServerEvent:Connect(function()
		sound:Destroy()
		local animation = Instance.new("Animation")
		animation.AnimationId = "rbxassetid://10223609210"
		local humanoid = player.Character:FindFirstChild("Humanoid")
		local AT = humanoid:LoadAnimation(animation)
		local sound2 = Instance.new("Sound")
		sound2.SoundId = "rbxassetid://10223776381"
		sound2.Parent = player.Character.HumanoidRootPart
		sound2.Volume = 0.75
		sound2:Play()
		AT:Play()
		Gatling = false
	end)
	repeat 
		wait(.065)
		local part = Instance.new("Part")
		part.Name = "Gatling"
		part.Parent = workspace
		part.Size = Vector3.new(1,1,2.5)
		part.Anchored = true
		part.Material = Enum.Material.SmoothPlastic
		part.Color = Color3.new(1, 0.839216, 0.65098)
		part.CanCollide = false
		local effect = game:GetService("ReplicatedStorage").Effects.Shockwave:Clone()
		effect.Parent = workspace
		effect.Size = Vector3.new(2, 2.1, 1.3)
		effect.Transparency = 0.65
		local RootPos, MousePos = part.Position, mousePos
		effect.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, MousePos.Y, MousePos.Z))
		effect.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(math.random(-3,3),math.random(-2.4,2.4),-2.8)
		effect.CanCollide = false
		effect.Anchored = true
		local RootPos, MousePos = part.Position, mousePos
		part.CFrame = CFrame.new(RootPos, Vector3.new(MousePos.X, MousePos.Y, MousePos.Z))
		part.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(math.random(-3,3),math.random(-2.4,2.4),-2.8)
		local TS = game:GetService("TweenService")
		local tweenInfo = TweenInfo.new(0.18, Enum.EasingStyle.Linear)
		local tween = TS:Create(effect,tweenInfo,{Transparency = 1}):Play()
		local tween1 = TS:Create(part,tweenInfo,{Transparency = 1})
		tween1:Play()
		tween1.Completed:Connect(function()
			part:Destroy()
			effect:Destroy()
			wait(0.1)
		end)
	until not Gatling
end)

game:GetService("ReplicatedStorage").Remotes.GumGatling.OnServerEvent:Connect(function(player)
	local hitbox = Instance.new("Part")
	local DB = false
	hitbox.Size = Vector3.new(6.5,6.5,5)
	hitbox.Anchored = true
	hitbox.CanCollide = false
	hitbox.Parent = workspace
	hitbox.Transparency = 1
	hitbox.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if not hit:IsDescendantOf(player.Character) then 
				if DB == false then
					DB = true
					hit.Parent.Humanoid.Health -= 5
					wait(.2)	
					DB = false
				end
				return end					
		end
	end)	
	game:GetService("ReplicatedStorage").Remotes.StopGumGatling.OnServerEvent:Connect(function()
		hitbox:Destroy()
	end)
	while true do 
		wait() 
		hitbox.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-2.8)
	end
end)

Its probably because StopGumGatling is getting fired which destroys the hitbox check the local script if you fired it early.

no because when i set the transparency to 0 its still there when it stops

try removing the return that might be it

it didn`t do a big difference.

then its probably .Touched itself if a part isnt constantly moving then it would stop firing after a while

i found how to do it, i just make the hitbox go back and forward, and it worked