NPC hits in a module multiple times

I’m having an issue where my punching module seems to fire multiple times when an NPC is doing it, however on a player it is completely fine.

The script that is used to initiate the punch are both very similar on the player and NPC, using a function from a module.
I think this portion from my punching module is the issue but I can’t seem to find what’s wrong or why the NPC would be any different?

AnimPlay:GetMarkerReachedSignal("Attack"):Connect(function()
		local Hitbox = Instance.new("Part")

		local overlap = OverlapParams.new()
		local Blacklist = {self.Character}
		overlap.FilterDescendantsInstances = Blacklist
		overlap.FilterType = Enum.RaycastFilterType.Exclude
		Hitbox.Parent = workspace
		Hitbox.Size = self.HitboxSize
		Hitbox.CFrame = self.Character.HumanoidRootPart.CFrame * self.HitBoxPosition
		Hitbox.CanCollide = false
		Hitbox.Transparency = 1
		Hitbox.Massless = true
		Hitbox.BrickColor = BrickColor.new("Really red")

		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = Hitbox
		Weld.Part0 = Hitbox
		Weld.Part1 =  self.Character.HumanoidRootPart
		game:GetService("Debris"):AddItem(Hitbox, (0.2))
		local HitContents = workspace:GetPartsInPart(Hitbox, overlap)
		if HitContents then
			for i, v in pairs(HitContents) do
				local HitValue = Instance.new("BoolValue")
				HitValue.Name = "PunchHit"
				HitValue.Value = false
				if v.Parent and v.Parent:FindFirstChild("Humanoid") and debounce == false and not v.Parent:FindFirstChild("PunchHit") then
					HitValue.Parent = v.Parent
					game:GetService("Debris"):AddItem(HitValue, 0.2)
					print("Added Value")
				end
				if v.Parent and v.Parent:FindFirstChild("Humanoid") and debounce == false and v.Parent:FindFirstChild("PunchHit").Value == false then
					HitValue.Value = true
					local TargetCharacter = v.Parent
					if game:GetService("RunService"):IsClient() then
						game.ReplicatedStorage.Remotes.Damage:FireServer(TargetCharacter, self.Damage, self.Knockback, self.Hitstun, self.Type, self.Effect)
						print("Fired Server")
					else
						local HitCharacter = Hit.new(TargetCharacter, self.Character, self.Damage, self.Knockback, self.Hitstun, self.Type, self.Effect)
						HitCharacter:Fire()
						print("Hit Module")
					end
				end
			end
		end
	end)

Help would be greatly appreciated!

I’ve found the solution myself, it wasn’t in this modulescript though it was a veery weird solution and case-specific so I won’t post the solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.