Ok so, I'm making some weapons, and there is some zombies, difference between a zombie and a player is that the zombies have an attribute in their humanoid, well, the weapon makes a hitbox by creating a part infront of the player, and checking for touched event to dmg the zombie.
This works perfectly, yet, the touched event fires alot of times as the zombie keeps touching the hitbox.
Using "debounce" wont work, because I want the weapon to be able to damage many zombies at once, just not the same ones.
So my question is:
How do I check if that zombie has already been damaged by the attack?
Here's my code if you need it:
hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.Humanoid:GetAttributes("IsNPC") then
local npc = hit.Parent
local hum = npc.Humanoid
hum:TakeDamage(35)
end
end
end)
"hitbox" is the part I use as the hitbox.

5 comments
Cool, I've used raycastHitbox v4.0 before, that is not my question tho.
then you can use something like a debounce but instead of bools you use the object value like local db = nil if db ~= Hit.parent then db = Hit.parent wait(1) db = nil end
Hmm I see, i will try doing that, i also took using my own raycasts into consideration, thanks!
It works, yet, there is a problem, when hitting many zombies at once, it will still spam the Touched event as db = hit.Parent keeps changing from zombie to zombie
Nevermind, figured it out using your idea of debounce but instead i made it into a table, thank for your help!