How to make Npc use hitbox module

how do i change this hitbox module, or allow it to be able be used by npcs?

the script bellow is the script I use to handle the npc attacking the player, I just have an issue with use the hitbox module as it is not a player, using character as the first param of the hitboxmodule returns an error.

local npc = workspace.DemonNpc
local hitboxModule = require(game:FindFirstChild("ReplicatedStorage").Modules.HitboxModule)
local module = require(game:GetService("ReplicatedStorage").Modules.CombatSystemModule)
local rs = game:GetService("ReplicatedStorage")

npc:SetAttribute('IsBlocking', false)
npc:SetAttribute("Stunned", false)
npc:SetAttribute("IsGaurdBroken", false)
npc:SetAttribute("Parried", false)
npc:SetAttribute("IsAttacking", false)
npc:SetAttribute("Parrying", false)
npc:SetAttribute("BlockValue", 100)
npc:SetAttribute("KnockBack", false)




npc:GetAttributeChangedSignal("KnockBack"):Connect(function()
	local KnockBack = npc:GetAttribute("KnockBack")
	if KnockBack == true then
		local KnockBackAnim = game:GetService("ReplicatedFirst").Animations.KnockBackAnim
		local KnockBackTrack = npc.Humanoid:LoadAnimation(KnockBackAnim)
		KnockBackTrack:Play()
		KnockBackTrack.Looped = false
	else
		print("player is not stunned")
	end

end)



local m1cooldown = false
local Runservice = game:GetService("RunService")
local DemonTorso = npc.Torso

local agrodistance = 100

local CombatNum = 1


game.Players.PlayerAdded:Connect(function(player)
	wait(1)
	local hum = player:FindFirstChild("Humanoid")
	local chr = player.Character

	local initialpos = DemonTorso.Position
	
	local Character = player.Character
	local bloodvfx = rs:WaitForChild("BloodVfx")

	local torso = chr.PrimaryPart

	local connection = Runservice.Heartbeat:Connect(function(deltaTime)
		local distance = (DemonTorso.Position  - torso.Position).Magnitude
		if distance < agrodistance and distance > 10 then
			npc.Humanoid:MoveTo(torso.Position)
			npc.Humanoid.WalkSpeed = 26
		elseif distance > agrodistance then
			
			npc.Humanoid:MoveTo(initialpos)
		end	
		
		if  distance < 10 and m1cooldown == false then
			m1cooldown = true
			npc.Humanoid.WalkSpeed = 8
			--module.CombatSystem(npc, CombatNum)
			CombatNum += 1
			for i,v in game:GetService("ReplicatedFirst").Animations.FistM1:GetChildren() do
				if tonumber(v.Name) == CombatNum then
					task.wait(1)
					local FistCombat = npc.Humanoid:LoadAnimation(v)
					FistCombat:Play()
					FistCombat:AdjustSpeed(0.8)
					hitboxModule.Hitbox()
					if CombatNum == 5 then
						--fistm2:FireServer()
						--task.wait(1)
						hitboxModule.Hitbox(Character, CFrame.new(0,0,-2.5), 7, 8,50,"no", bloodvfx)
						print("5th m1")
					end
				end
	        end
			if CombatNum > 5 then
				CombatNum = 1
			end
			task.wait(1)
			m1cooldown = false
			
		end
	end)
end)

script bellow is the hitbox module

local module = {}

module.Hitbox = function(Character:Model, CFrameOffset:CFrame, Size:number, Damage:number, BlockDamage:number, KnockBack, VfxPart:BasePart)
	local Hrp = Character:FindFirstChildOfClass("Humanoid").RootPart
	local String = Instance.new("StringValue")
	String.Name = KnockBack
	local player = game.Players:GetPlayerFromCharacter(Character)
	local rs = game:GetService("ReplicatedStorage")
	
	local Hitbox = workspace:GetPartBoundsInBox(Hrp.CFrame * CFrameOffset, Vector3.one * Size)

	local Filtered = {}

	for _, Parts in Hitbox do
		local PossibleCharacter = Parts.Parent

		if PossibleCharacter == Character or table.find(Filtered, PossibleCharacter) then continue end

		local Humanoid = PossibleCharacter:FindFirstChild("Humanoid")
		if not Humanoid then continue end
		local VfxClone = VfxPart:Clone()
		local ParryVfx = rs.ParryVfx:Clone()

		local PossiblePlayer = game.Players:GetPlayerFromCharacter(PossibleCharacter)
		if PossiblePlayer then

			local leaderstats = PossiblePlayer:WaitForChild("leaderstats")
			local BlockValue = leaderstats.BlockValue

			if PossibleCharacter:GetAttribute("IsBlocking") == true and PossibleCharacter:GetAttribute("Parrying") == false and PossibleCharacter:GetAttribute("IsGaurdBroken") == false then
				BlockValue.Value -= BlockDamage
			end

			if PossibleCharacter:GetAttribute("IsBlocking") == false and PossibleCharacter:GetAttribute("Parrying") == false and PossibleCharacter:GetAttribute("IsGaurdBroken") == false then
				if KnockBack == "yes"  then
					local bodyVelocity = Instance.new("BodyVelocity")
					bodyVelocity.Name = "KNOCKBACK"
					bodyVelocity.MaxForce = Vector3.new(100000000, 0, 100000000)
					bodyVelocity.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector.unit * 30
					PossibleCharacter:SetAttribute("KnockBack", true)
					bodyVelocity.Parent = PossibleCharacter.HumanoidRootPart
					Humanoid:TakeDamage(Damage)
					game.Debris:AddItem(bodyVelocity, 0.65)
					PossibleCharacter:SetAttribute("KnockBack", false)


				else
					Humanoid:TakeDamage(Damage)
					VfxClone.CFrame = Humanoid.RootPart.CFrame
					VfxClone.Parent = workspace

					PossibleCharacter:SetAttribute("Stunned", true)
					task.wait(1)
					PossibleCharacter:SetAttribute("Stunned", false)
				end
			end

			if PossibleCharacter:GetAttribute("IsBlocking") == true and PossibleCharacter:GetAttribute("Parrying") == true and PossibleCharacter:GetAttribute("IsGaurdBroken") == false then
				--local katanaParry = game:GetService("ReplicatedFirst").Animations.KatanaParry
				--local KatanaParryTrack = hum:LoadAnimation(katanaParry)
				--KatanaParryTrack:Play()
				ParryVfx.Parent = workspace
				ParryVfx.CFrame = PossibleCharacter:WaitForChild("Humanoid").RootPart.CFrame

			end
			game.Debris:AddItem(ParryVfx,0.5 )
			
		else
			local NpcChar = Humanoid.Parent
			
			if NpcChar:GetAttribute("IsBlocking") == true and NpcChar:GetAttribute("Parrying") == false and NpcChar:GetAttribute("IsGaurdBroken") == false then
				NpcChar:SetAttribute("BlockValue", NpcChar:GetAttribute("BlockValue") - BlockDamage)
			end

			if NpcChar:GetAttribute("IsBlocking") == false and NpcChar:GetAttribute("Parrying") == false and NpcChar:GetAttribute("IsGaurdBroken") == false then
				if KnockBack == "yes"  then
					local bodyVelocity = Instance.new("BodyVelocity")
					bodyVelocity.Name = "KNOCKBACK"
					bodyVelocity.MaxForce = Vector3.new(100000000, 0, 100000000)
					bodyVelocity.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector.unit * 30
					NpcChar:SetAttribute("KnockBack", true)
					bodyVelocity.Parent = NpcChar.HumanoidRootPart
					Humanoid:TakeDamage(Damage)
					game.Debris:AddItem(bodyVelocity, 0.65)
					task.wait(0.6)
					NpcChar:SetAttribute("KnockBack", false)
					
					
				else
					Humanoid:TakeDamage(Damage)
					VfxClone.CFrame = Humanoid.RootPart.CFrame
					VfxClone.Parent = workspace

					NpcChar:SetAttribute("Stunned", true)
					task.wait(1)
					NpcChar:SetAttribute("Stunned", false)
				end
			end

			if NpcChar:GetAttribute("IsBlocking") == true and NpcChar:GetAttribute("Parrying") == true and NpcChar:GetAttribute("IsGaurdBroken") == false then
				--local katanaParry = game:GetService("ReplicatedFirst").Animations.KatanaParry
				--local KatanaParryTrack = hum:LoadAnimation(katanaParry)
				--KatanaParryTrack:Play()
				ParryVfx.Parent = workspace
				ParryVfx.CFrame = NpcChar:WaitForChild("Humanoid").RootPart.CFrame

			end
			
		end

			
		

		table.insert(Filtered, PossibleCharacter)
		task.delay(0.5, game.Destroy, VfxClone, ParryVfx)
	end

	table.clear(Filtered)
end

return module

  1. Check whether NPC is close enough to the actual player
  2. Assuming it is, spawn a hitbox in front of the NPC’s model, detect hits, validate that those hits are players and do damage.

You could like make so the hitbox module takes in a blacklist array, of all Character Models / NPCs that can’t be detected by the hitbox, so that when you use hitbox as a player, you can perhaps pass self as a blacklist or other NPC’s. And when a NPC is using the module, you would pass all NPC models so they don’t get detected. Somewhat like that, you get the idea I hope