How would I make the .Touched function hit more than one person?

I have a hitbox, but the problem is, I want it to hit multiple people, but still not hit someone that was already hit by it more than once, how would I go about doing this?

Hit part of my code:

		local OnCooldown = false

		Hitbox.Touched:Connect(function(Hit)
			if not Hit:IsDescendantOf(Character) and Hit and Hit.Parent then
				local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
				if Humanoid then
					if OnCooldown == false then
						OnCooldown = true
						Humanoid:TakeDamage(Damage)

					end
				end
			end
		end)
1 Like

Personally what I do is a table containing all touched characters, like this:

local Hits = {}
		Hitbox.Touched:Connect(function(Hit)
			if not Hit:IsDescendantOf(Character) and Hit and Hit.Parent then
				local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
				if Humanoid and not table.find(Hits, Hit.Parent) then
					        table.insert(Hits, Hit.Parent)
						Humanoid:TakeDamage(Damage)

					end
				end
			end
		end)
2 Likes

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