Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

I need help with my sword, it's dealing damage the first hit then stops. Can anyone help fix it?

Asked by 9 days ago

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?

0
And I know it's late, so I might not been on if someone answers. protectiverobos -50 — 9d
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. PhantomVisual 338 — 9d
0
Don't ever worry about not being on when someone answers, we all understand we're probably in different timezones. SteamG0D 579 — 9d
0
Also why do you have it in 2 different scripts if they are both children of the same object? SteamG0D 579 — 9d
View all comments (5 more)
0
I changed it PhantomVisual, and nothing changed. And idk why I have 2 scripts. protectiverobos -50 — 9d
0
Would it help if I combine them? protectiverobos -50 — 9d
0
Also, I'm testing it more and CanDamage is always true. protectiverobos -50 — 9d
0
output? Clasterboy -8 — 8d
0
Nothings in the output protectiverobos -50 — 8d

Answer this question