Sword damaging player after not initially touching player

I am writing a script right now for a sword. If the hitbox is touched by a humanoid it fires the server to damage the humanoid. My problem is even thought the hitbox isn’t being touched by the “enemy” or other humanoid it fires the server. I linked a video in case I didn’t explain well enough

ezgif-2-e040d2ffd7

Local Script

local lcPlayer = players.LocalPlayer
local hum = lcPlayer.Character.Humanoid
local katana = script.Parent
local hitBox = katana.BladeHitbox
local handle = katana.Handle
local DmgEvent = game.ReplicatedStorage.Damage
local DmgEventSlash = game.ReplicatedStorage.DamageSlash

local canDamage = true
local canAttack = true
local specialATK = false
local cooldown = 2
local combatCount = 0


local slashAnim = katana.Slash
local slashTrack = hum:LoadAnimation(slashAnim)
local kendoAnim = katana.Kendo
local kendoTrack = hum:LoadAnimation(kendoAnim)

local UIS = game:GetService("UserInputService")




UIS.InputBegan:Connect(function(input,gpe)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if canAttack == true then
			
			kendoTrack:Play()
			
			if hitBox.Touched and hum and kendoTrack.IsPlaying then
				DmgEvent:FireServer()
			end
			
		
			
			canAttack = false
			
			wait(cooldown)
			canAttack = true

		end
	end
end)

Server Script

local katana = workspace.WoodKatana
local hitBox = katana.BladeHitbox
local DmgEvent = game.ReplicatedStorage.Damage
local DmgEventSlash = game.ReplicatedStorage.DamageSlash


local canDamage = true
local specialATK = false
local combatCount = 0
local clicked = false



local function Dmg(hit) --Function called dmg with param hit

	local hum = hit.Parent:WaitForChild("Humanoid") -- Defines hum 
	local wielder = katana.Parent --Defines plr wielding sword


	if hum and clicked == true then

		canDamage = true
		
		if canDamage == true then
			
			hum:TakeDamage(5)
		end
	end
	
	clicked = false
	canDamage = false --Sets canDmg to false so you have to click again to run

end


DmgEvent.OnServerEvent:Connect(function(player) -- Starts server event
	
	clicked = true

	hitBox.Touched:Connect(Dmg) -- if hitbox is touched connect dmg function


end) -- End of server event
``lua
2 Likes
DmgEvent.OnServerEvent:Connect(function(player)
	clicked = true
	hitBox.Touched:Connect(Dmg)
end)

This .Touched connection is created each time the outer OnServerEvent RBXScriptSignal object (event) is fired.

You need to appropriately disconnect this .Touched event connection.

how do I disconnect the Touched event?

local c = hitBox.Touched:Connect(dmg)
wait(0.3)
c:Disconnect()