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

Damage not consistent and script breaks in a Damage script?

Asked by 3 years ago

Hi, i have a pretty weird problem with my script: Basically, I'm making a weapon, and it should only take damage when it's activated. The purpose of this is to avoid the player from just walking to a humanoid, and it takes damage, so they have to activate it. It works the first time, but then after a few times I don't have to activate the tool for it to do damage, and it does like 100 damage

local Hammer = script.Parent
local DamagePart = Hammer.Handle.DamagePart

Hammer.Activated:Connect(function()
    DamagePart.Touched:Connect(function(Hit)
        local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
        if Humanoid then
            Humanoid:TakeDamage(2)
        end
    end)
end)

Answer this question