Multiple Boxes for hitboxes

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

Im trying to make multiple boxes that acts as hitboxes for more easier hits but the problem is after some times it keeps adding more damage than the supposed 15

function Slash() -- M1 ABILITY
	
	--[[local Speed = 40
	local Force = 80000

	local TotalForce = Force

	local KnockBack = Instance.new("BodyVelocity")
	KnockBack.Parent = part.Parent:FindFirstChild("HumanoidRootPart")--part is the target of the knockback/ the opponent

	KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)
	KnockBack.Velocity = Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed -- based on the direction YOUR character is facing.]]
	
	if canM1 and AllLocked == false then
			
		if Configuration.Stats.Linked_Sword.Value == true then	
			
			print("Swing")
			
			canM1 = false
			M1Anim:Play(0)
			local hitTble = {}
			AllLocked = true

			M1Anim:GetMarkerReachedSignal("HITBOX"):Connect(function()

				local atch = Instance.new("Attachment")
				atch.Parent = Character.HumanoidRootPart
				local hitbox = hitboxMod.create(atch.WorldCFrame*CFrame.new(0,0,-3), Vector3.new(6, 5, 4), 0.125)
					hitbox.Touched:Connect(function(hit)
						local victim = hit.Parent

						if victim:FindFirstChildWhichIsA("Humanoid") and not table.find(hitTble, victim) and victim ~= Character then
							table.insert(hitTble, victim)
							print(hitTble)
							hitbox.BrickColor = BrickColor.new("Lime green")
						--	print(victim)
							
							game.ReplicatedStorage.Events.Damage:FireServer(victim,M1Dmg)
							

						end
					end)
					task.wait()
			
			end)
		
		

		task.wait(M1Anim.Length+0.05)
		
		AllLocked = false
		
		task.wait(durationM1-M1Anim.Length-0.05)
		
		canM1 = true
		end
	end
end

It might be that you’re not cleaning up your connections because they will still run after that functions completes, try replacing all the :Connect with :Once .

3 Likes

I tried putting once but now it does not detect if the Killer hit multiple chars and still does the damage error

I printed the tables and it looks like after each time I swing it keeps the same table stored is there a way to like disconnect the table or reset the table every time I swing

Fixed it with making the Hitboxes creation a connection that I can disconnect every time

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