Hi, I have a sword with two scripts, and the sword only deals damage on the first hit. It gives no errors, and I cant find out whats wrong with it.

1st script

script.Parent.Blade.Touched:connect(function(p)

if script.Parent.CanDamage.Value == true then

script.Parent.CanDamage.Value = false

if p.parent.Zombie then

p.Parent.Zombie:TakeDamage (script.Parent.Damage.Value)

end
else
end
end)

2nd Script

local CanAttack = true
script.Parent.Activated:connect(function()

local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)

if CanAttack == true then

attack:Play()
CanAttack = false
wait(1)
attack:Stop()
CanAttack = true
script.Parent.CanDamage.Value = true

end
end)

I have everything inside the sword and it doesn't work, does anyone see any problems?

9 comments

0

And I know it's late, so I might not been on if someone answers.

0

script.Parent.CanDamage.Value = true; this line should be after CanAttack is set to false (or after the attack animation is played). Our goal here is to damage while the attacking animation is playing.

0

Don't ever worry about not being on when someone answers, we all understand we're probably in different timezones.

0

Also why do you have it in 2 different scripts if they are both children of the same object?

0

I changed it PhantomVisual, and nothing changed. And idk why I have 2 scripts.

0

Would it help if I combine them?

0

Also, I'm testing it more and CanDamage is always true.

0

output?

0

Nothings in the output