Hi, I am not very good at scripting and got some help with a script. But the problem is the when the animation is off and you get to close to a player. u kill the player. I want it to make it so if the animation is not playing, you cant kill the player. I have a bool value called swinging when the animation plays. I want to connect the script below to match the animation and if the animation doesn't play, you cant damage.
Script -
local damage = 20
local cooldown = 2 -- in seconds
local enabled = true
script.Parent.Union.Touched:Connect(function(p)
if enabled == false then
return
end
local Humanoid = p.Parent:FindFirstChild('Humanoid')
if Humanoid then -- only run script of the part it hits is a body part of a character.
enabled = false
Humanoid:TakeDamage(damage)
wait(cooldown)
end
enabled = true
end)
