Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Zombie Damages even when their not touching me?

Asked by
Erie20 102
4 years ago
local Zombie = script.Parent
local Cooldown =  require(game:GetService("ServerScriptService").ZombieCooldownModule)
local wave -- for wave stuff
local debounce

while true do
    for _, child in ipairs(Zombie:GetChildren()) do
        if child:IsA("BasePart") then
            child.Touched:Connect(function(part)
                local partParent = part.Parent
                local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")

                if not humanoid then 
                    return
                else
                if humanoid and partParent.name ~= "Zombie" and Zombie.Humanoid.Health ~= 0 then
                    if not Cooldown:Check(partParent) then
                        humanoid.Health = humanoid.Health - 10

                        local currenttime = os.time()
                        Cooldown:Add(partParent,currenttime)
                    end

                end 
                end

            end)        
        end
    end
    wait(1)
end

The above code is supposed to damage the player when the script parent touches the player. However, even after the player stops touching the script parent, it continues to damage.

I can't figure out the bug, and I'm almost certain that the bug occurs here.

1
Try removing the last 2 lines and the while true do. raid6n 2196 — 4y
0
@raid6n I'll try that. Erie20 102 — 4y

Answer this question