The problem with this script is that if you don't attack while you're moving, sometimes it's like the .Touched doesn't work therefore no damage is done.
local player = game.Players.LocalPlayer
local animation = script:WaitForChild("Animation")
local activated = false
local played = false
local Settings = script.Parent:WaitForChild("Settings")
local dmg = Settings:WaitForChild("Damage")
function play()
played = true
local animationTrack = player.Character.Humanoid:LoadAnimation(animation)
animationTrack:Play()
Settings:WaitForChild("Sound1"):Play()
wait(0.2)
played = false
end
script.Parent.Activated:connect(play)
function damage(hit)
activated = true
if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent.Name ~= player.Name and player.Character:FindFirstChild("Humanoid").Health ~= 0 and activated == true and played == true then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(dmg.Value)
Settings:WaitForChild("Sound2"):Play()
end
wait(0.2)
activated = false
played = false
end
script.Parent.Handle.Touched:connect(damage)
function untouch()
activated = false
played = false
end
script.Parent.Handle.TouchEnded:connect(untouch)
