so I wanted to make an explosion, and whenever it hits someone, it gets their character name, and I run a check to see if their name was already in the table, if it already was, it will not damage them. However, it does not work, and it damages them multiple times. What do I do?
script:
local part = script.Parent
local partsHit = {"hi"}
local caster = script.Caster-- the person who casted the explosion
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local charName = hit.Parent.Name
if hum ~= nil and hum.Parent.Name ~= caster.Value then
for i, thing in pairs(partsHit) do
if thing ~= charName then
hum:TakeDamage(10)
table.insert(partsHit, #partsHit + 1, charName)
end
end
end
end)
