How do I make my hitbox hit multiple humanoids at once?

I created a tool which uses the model as the hit box, and it works however, it doesn’t hit multiple characters in one swing

Here is the script file; the script is also at the end of this post:

HitBoxAGAIN.lua (2.9 KB)

Here is where the script is located if that’s relevant:

image_2023-09-18_214204974
and here is where I believe the issue is:

Normal:

Without Disconnect (doesn’t matter if I put a debounce):

local Hitbox = script.Parent
local remote = game.ReplicatedStorage.AttackEvent
local damageDone = 99
local hitlist = game.Workspace.HitList:GetChildren()

local connection = nil

local function KnockBack(pChar, eChar)
	if pChar and eChar then
		local pHrp = pChar:FindFirstChild("HumanoidRootPart")
		local eHrp = eChar:FindFirstChild("HumanoidRootPart")
		if pHrp and eHrp then
			local dir = (eHrp.Position - pHrp.Position).Unit
			local att = Instance.new("Attachment", eHrp)
			local force = Instance.new("VectorForce", eHrp)
			force.Attachment0 = att
			force.Force = (dir + Vector3.new(0,1,0)).Unit * 9000
			force.RelativeTo = Enum.ActuatorRelativeTo.World
			eChar.Humanoid.PlatformStand = true
			local rot = Instance.new("AngularVelocity", eHrp)
			rot.Attachment0 = att
			rot.AngularVelocity = Vector3.new(1,0,1) * 10
			rot.MaxTorque = math.huge
			rot.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			game.Debris:AddItem(force, .1)
			game.Debris:AddItem(rot, .1)
			game.Debris:AddItem(att, .1)
			wait(0.5)
			eChar.Humanoid.PlatformStand = false
		end
	end
end

local function SentToSpace(pChar, eChar) -- use if char.health <= 10
	if pChar and eChar then
		local pHrp = pChar:FindFirstChild("HumanoidRootPart")
		local eHrp = eChar:FindFirstChild("HumanoidRootPart")
		if pHrp and eHrp then
			local dir = (eHrp.Position - pHrp.Position).Unit
			local att = Instance.new("Attachment", eHrp)
			local force = Instance.new("VectorForce", eHrp)
			force.Attachment0 = att
			force.Force = (dir + Vector3.new(0,1,0)).Unit * 10000
			force.RelativeTo = Enum.ActuatorRelativeTo.World
			eChar.Humanoid.PlatformStand = true
		end
	end
end



remote.OnServerEvent:Connect(function(player)
	connection = Hitbox.Touched:Connect(function(other_object)
		
		if not hitlist then return end
		print("passed1")
		local humanoid = other_object.Parent:FindFirstChild("Humanoid")
		if not humanoid then
			connection:Disconnect()
			print("nothum")
		end
		
		if humanoid then
			if humanoid.Health <= 0 then 
				print("huamnoiddead")
				connection:Disconnect()
			else
				
				connection:Disconnect()
				humanoid:TakeDamage(100)
				local sounds = game.ReplicatedStorage.Sound
				local HitPunchSFX = sounds.hit_punch_l:Clone()
				local WoodBreakSFX = sounds.wood_solid_impact_bullet2:Clone()
				local VFX = game.ReplicatedStorage.HitVFX.Attachment.ParticleEmitter:Clone()
				VFX.Parent = other_object.Parent.Torso
				VFX:Emit(1)
				game.Debris:AddItem(VFX, 1.2)
				HitPunchSFX.Parent = other_object.Parent.Torso
				WoodBreakSFX.Parent = other_object.Parent.Torso
				HitPunchSFX.Volume = 1
				WoodBreakSFX.Volume = 0.2
				KnockBack(player.Character, other_object.Parent)
				HitPunchSFX:Play()
				WoodBreakSFX:Play()
				connection:Disconnect()
				
			end
		end
	end)	
	task.wait(1.3)
	connection:Disconnect()
end)
2 Likes

You’re disconnecting the connection so it can’t detect the second humanoid.

1 Like

1 Like

you can modify it so that it doesn’t disconnect the connection right away after the first hit, make it disconnect after a certain timeframe, then create a debouncing table where it stores boolean of each humanoids whether are they on debounce or not, then remove their debounce after another timeframe

1 Like

You have disconnected from the humanoid, so it won’t detect the second humanoid.

something like this?

remote.OnServerEvent:Connect(function(player)
	local alreadyHit = {}

	connection = Hitbox.Touched:Connect(function(other_object)
		if not hitlist then return end
		if alreadyHit[other_object.Parent] then return end
		
		local humanoid = other_object.Parent:FindFirstChild("Humanoid")
		if not humanoid then
			return
		end
		
		if humanoid then
			if humanoid.Health <= 0 then 
				return
			end
				
			alreadyHit[other_object.Parent] = true

			humanoid:TakeDamage(100)
			local sounds = game.ReplicatedStorage.Sound
			local HitPunchSFX = sounds.hit_punch_l:Clone()
			local WoodBreakSFX = sounds.wood_solid_impact_bullet2:Clone()
			local VFX = game.ReplicatedStorage.HitVFX.Attachment.ParticleEmitter:Clone()
			VFX.Parent = other_object.Parent.Torso
			VFX:Emit(1)
			game.Debris:AddItem(VFX, 1.2)
			HitPunchSFX.Parent = other_object.Parent.Torso
			WoodBreakSFX.Parent = other_object.Parent.Torso
			HitPunchSFX.Volume = 1
			WoodBreakSFX.Volume = 0.2
			KnockBack(player.Character, other_object.Parent)
			HitPunchSFX:Play()
			WoodBreakSFX:Play()
		end
	end)	
	task.wait(1.3)
	connection:Disconnect()
	table.clear(alreadyHit)
end)
1 Like


WHAAAAAAAT. I DIDN’T THINK ABOUT USING TABLE.CLEAR. THANK YOU

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