Sword tool stops working after one use?
This is a regular script in a sword tool that does damage once but stops working after one use. Help is appreciated. Thanks.
01 | local Hitbox = script.Parent.Hitbox |
02 | local CanDamage = script.Parent.LocalScript.CanDamage |
04 | local CDDebounce = false |
07 | script.Parent.Activated:Connect( function () |
08 | if CDDebounce = = false then |
09 | CanDamage.Value = true |
12 | CanDamage.Value = false |
19 | Hitbox.Touched:Connect( function (hit) |
20 | if CanDamage.Value = = true then |
21 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
22 | if hit.Parent.CanTakeDamage.Value = = true then |
23 | hit.Parent.CanTakeDamage.Value = false |
24 | local StraightSwordHit = hit.Parent.Humanoid:LoadAnimation(script.Parent.Anim.StraightSwordHit) |
25 | hit.Parent.Humanoid:TakeDamage( 30 ) |
26 | StraightSwordHit:Play() |
27 | hit.Parent.Humanoid.WalkSpeed = 0 |
29 | local ForceField = Instance.new( "ForceField" ) |
30 | ForceField.Name = "DamageInvincibility" |
31 | ForceField.Parent = hit.Parent |
35 | hit.Parent.Humanoid.WalkSpeed = 0 |
36 | hit.Parent.CanTakeDamage.Value = true |