#After using my tool once, every time my hitpart of the tool touches the enemy he dies in 1 second.

1 messages · Page 1 of 1 (latest)

fossil oar
#

The enemy just dies in 1 second with 1000 hp.

local Tool = script.Parent
local HitPart = Tool.Handle
local Anim = script.Animation
local DB = false

Tool.Activated:Connect(function(Player)
if DB == false then
DB = true

    local Charachter = Tool.Parent
    local Humanoid = Charachter:WaitForChild("Humanoid")
    local Animator = Humanoid:WaitForChild("Animator")
    local AnimationTrack = Animator:LoadAnimation(Anim)
    
    AnimationTrack:Play()
    
    HitPart.Touched:Connect(function(hit)
        
        local EnemyHumanoid = hit.Parent:WaitForChild("Humanoid")
        local Hit_Animation = game.ReplicatedStorage:FindFirstChild("Enemy_Hit_Folder"):FindFirstChild("Hit_Animation")
        local Enemy_Animator = EnemyHumanoid:WaitForChild("Animator")
        local AnimationTrack_Enemy = Enemy_Animator:LoadAnimation(Hit_Animation)


        EnemyHumanoid:TakeDamage(20)
        AnimationTrack_Enemy:Play()
        
    end)
end

end)

while true do
task.wait(1)
DB = false
end

short echo
#

I belive, its because there is no debounce inside HitPart.Touched.

fossil oar
# short echo I belive, its because there is no debounce inside HitPart.Touched.

local Tool = script.Parent
local HitPart = Tool.Handle
local Anim = script.Animation
local DB = false
local AnimCD = false

Tool.Activated:Connect(function(Player)

    local Charachter = Tool.Parent
    local Humanoid = Charachter:WaitForChild("Humanoid")
    local Animator = Humanoid:WaitForChild("Animator")
    local AnimationTrack = Animator:LoadAnimation(Anim)
    
    
    if AnimCD == false then
        AnimCD = true
    AnimationTrack:Play()
    else
        return
    end

    
    HitPart.Touched:Connect(function(hit)        
    if DB == false then
        DB = true
        
        local EnemyHumanoid = hit.Parent:WaitForChild("Humanoid")
        local Hit_Animation = game.ReplicatedStorage:FindFirstChild("Enemy_Hit_Folder"):FindFirstChild("Hit_Animation")
        local Enemy_Animator = EnemyHumanoid:WaitForChild("Animator")
        local AnimationTrack_Enemy = Enemy_Animator:LoadAnimation(Hit_Animation)


        EnemyHumanoid:TakeDamage(20)
        AnimationTrack_Enemy:Play()
    end
    
    task.wait(1)
    AnimCD = false
    DB = false
    
end)

end)

Updated script and still same bug

gloomy lava
#

try this:local Tool = script.Parent
local HitPart = Tool.Handle
local Anim = script.Animation
local DB = false

Tool.Activated:Connect(function(Player)
if DB then return end
DB = true

    local Charachter = Tool.Parent
    local Humanoid = Charachter:WaitForChild("Humanoid")
    local Animator = Humanoid:WaitForChild("Animator")
    local AnimationTrack = Animator:LoadAnimation(Anim)

    AnimationTrack:Play()

    HitPart.Touched:Connect(function(hit)

        local EnemyHumanoid = hit.Parent:WaitForChild("Humanoid")
        local Hit_Animation = game.ReplicatedStorage:FindFirstChild("Enemy_Hit_Folder"):FindFirstChild("Hit_Animation")
        local Enemy_Animator = EnemyHumanoid:WaitForChild("Animator")
        local AnimationTrack_Enemy = Enemy_Animator:LoadAnimation(Hit_Animation)


        EnemyHumanoid:TakeDamage(20)
        AnimationTrack_Enemy:Play()
    end)
    
    task.delay(1, function()
        DB = false
        
end)

end)

fossil oar
charred zinc
#

try this

local Tool = script.Parent
local HitPart = Tool.Handle
local Anim = script.Animation
local DB = false

Tool.Activated:Connect(function(Player)
if DB == false then
DB = true

    local Charachter = Tool.Parent
    local Humanoid = Charachter:WaitForChild("Humanoid")
    local Animator = Humanoid:WaitForChild("Animator")
    local AnimationTrack = Animator:LoadAnimation(Anim)

    AnimationTrack:Play()

    HitPart.Touched:Connect(function(hit)
        if DB then return end

        local EnemyHumanoid = hit.Parent:WaitForChild("Humanoid")
        local Hit_Animation = game.ReplicatedStorage:FindFirstChild("Enemy_Hit_Folder"):FindFirstChild("Hit_Animation")
        local Enemy_Animator = EnemyHumanoid:WaitForChild("Animator")
        local AnimationTrack_Enemy = Enemy_Animator:LoadAnimation(Hit_Animation)


        EnemyHumanoid:TakeDamage(20)
        AnimationTrack_Enemy:Play()
    end)
    
    task.wait(1)
    DB = false 
end

end)

fossil oar