for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA(“BasePart”) then
v.Touched:Connect(function(hit)
if DB == true then return end
if hit == nil then return end
if hit.Parent == nil then return end
local vhum = hit.Parent:FindFirstChild(“Humanoid”)
if vhum ~= nil then
if hum.Health <= 0 then return end
if vhum ~= hum and not hit.Parent:FindFirstChild(“ZombieScript”) then – keeps it from hurting itself/ zombies
vhum:TakeDamage(math.random(1, 3))
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if vhum.Health <= 0 and plr then
end
DB = true
task.wait(1)
DB = false
end
end
end)
end
DB = false
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA(“BasePart”) then
v.Touched:Connect(function(hit)
if DB == true then return end
if hit == nil then return end
if hit.Parent == nil then return end
local vhum = hit.Parent:FindFirstChild(“Humanoid”)
if vhum ~= nil then
if hum.Health <= 0 then return end
if vhum ~= hum and not hit.Parent:FindFirstChild(“ZombieScript”) then – keeps it from hurting itself/ zombies
vhum:TakeDamage(math.random(1, 3))
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if vhum.Health <= 0 and plr then
end
end
DB = true
task.wait(1)
DB = false
end
end)
end
end
``
maybe moving the debounce can change something
The debounce is put outside the loop meaning that it won’t actually function as intended, you may want to put it inside the loop, after if v:IsA(“BasePart”) then so it will work separately for different parts, reducing the lag.