I am working on a sword right now and everything is fine and perfect until I found out that my sword can only deal damage once and once only. I made another question on how to make the sword only deal damage when it was clicked and it's fixed, but now it created another problem, which is this. All the animation works, the main problem is just that it's only doing damage once. Please help!
Local Script
local CanAttack = true
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local idle = char:WaitForChild("Humanoid"):LoadAnimation(script.idle)
local attack = char:WaitForChild("Humanoid"):LoadAnimation(script.attack)
script.Parent.Equipped:Connect(function()
idle:Play()
script.Parent.Activated:Connect(function()
if CanAttack then
idle:Stop()
attack:Play()
CanAttack = false
idle:Play()
wait(1)
attack:Stop()
CanAttack = true
script.Parent.CanDamage.Value = true
end
end)
end)
script.Parent.Unequipped:Connect(function()
idle:Stop()
end)
** Normal Script**
script.Parent.blade.Touched:Connect(function(p)
if script.Parent.CanDamage.Value == true then
p.Parent.Humanoid:TakeDamage(20)
script.Parent.CanDamage.Value = false
end
end)

1 comment
I tried out this new code, but I didn't even get a chance to left click to attack the dummy because it was taking lots of damage when it touched the blade.