This is a regular script in a sword tool that does damage once but stops working after one use. Help is appreciated. Thanks.
local Hitbox = script.Parent.Hitbox
local CanDamage = script.Parent.LocalScript.CanDamage
local CanTouch = true
local CDDebounce = false
script.Parent.Activated:Connect(function()
if CDDebounce == false then
CanDamage.Value = true
delay(1.1, function()
CanDamage.Value = false
CDDebounce = true
end)
end
end)
Hitbox.Touched:Connect(function(hit)
if CanDamage.Value == true then
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.CanTakeDamage.Value == true then
hit.Parent.CanTakeDamage.Value = false
local StraightSwordHit = hit.Parent.Humanoid:LoadAnimation(script.Parent.Anim.StraightSwordHit)
hit.Parent.Humanoid:TakeDamage(30)
StraightSwordHit:Play()
hit.Parent.Humanoid.WalkSpeed = 0
local ForceField = Instance.new("ForceField")
ForceField.Name = "DamageInvincibility"
ForceField.Parent = hit.Parent
delay(1.2, function()
ForceField:Destroy()
hit.Parent.Humanoid.WalkSpeed = 0
hit.Parent.CanTakeDamage.Value = true
end)
end
end
end
end)

2 comments
any errors?
Nope, just doesn't work.