Hello, I have a mine for a zombie game, and when a zombie steps on it it is supposed to damage whoever stepped on it and the surrounding zombies. Because the zombies are clones, I am unable to verify if a zombie has already been hit because a hit zombie is identical to a zombie that has not yet been hit in an explosion's radius, and if I put a debounce, the explosion will only damage the first zombie it touches and stop. Is there any way I can add a variable to a hit zombie so I can identify if it has already been hit? (I am planning to make it so the zombie can be hit again by another mine, so I would need to sort that out later on, but for now this is a big road block for me.)
Here is the code. Thank you very much.
part = script.Parent
lastHuman = nil
repeated = true
part.Touched:Connect(function()
if repeated then
repeated = false
print("startExplosion")
local Explosion = Instance.new("Explosion")
Explosion.DestroyJointRadiusPercent = 0
Explosion.Position = script.Parent.Position
Explosion.BlastRadius = 20
Explosion.BlastPressure = 20000
Explosion.Parent = game.Workspace
local MIN_DAMAGE = 0
local MAX_DAMAGE = 10
Explosion.Hit:Connect(function(hit, distance)
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if hum == lastHuman then
print(hum)
print(lastHuman)
end
lastHuman = hum
if hum then
hum:TakeDamage((1 - distance / Explosion.BlastRadius) * (MAX_DAMAGE - MIN_DAMAGE) + MIN_DAMAGE)
print("BLOWN UP")
end
end)
end
end)'
#####Re-edited by JesseSong!
