Hitbox Damage Issue, make the damage function work if multiple characters touched it

  1. What do you want to achieve? Keep it simple and clear!
    I’m basically making a hitbox system that damages characters with humanoid that touches it and I need to make it damage multiple characters if multiple players touched it, but as well not damage them twice.

  2. What is the issue? Include screenshots / videos if possible!

I need help on how to make it, I’ve have tried to using table.insert/find but it just seems to not work or bug out, but any help would be appreciated.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried looking it up but the only thing that helped me was by using tables but it just doesn’t want to work for me.

Currently I have this script to damage a singular player only, I want to make this work to damage to multiple players without having damaging them twice.

repeat task.wait()
		local HitTable = game.Workspace:GetPartsInPart(Part, Params)
		for i,v in ipairs(HitTable) do
			local Humanoid = v.Parent:FindFirstChildOfClass("Humanoid")
			if Humanoid ~= nil then
				script:WaitForChild("HitboxRemote"):FireServer(Humanoid)
				Hum = Humanoid
				break
			end
		end
	until Destroy == true or Hum ~= nil

Like for some reason, this wouldn’t work.

repeat task.wait()
		local HitTable = game.Workspace:GetPartsInPart(Part, Params)
		for i,v in ipairs(HitTable) do
			local Humanoid = v.Parent:FindFirstChildOfClass("Humanoid")
			if Humanoid ~= nil then
				if not table.find(HumTable, Humanoid) then
					table.insert(HumTable, Humanoid)
					print(HumTable)
				else
					return print('test')
				end
				--script:WaitForChild("HitboxRemote"):FireServer(Humanoid)
				--Hum = Humanoid
				--break
			end
		end
	until Destroy == true -- or Hum ~= nil

Fixed it yesterday, so no need to worry now.

1 Like