so the problem is that it saves the click so i can click the sword and 30 seconds later touch the humanoid and it takes damage i dont know how to fix it
IsTouching = false
CanDamage = script.Parent.CanDamage.Value
script.Parent.Activated:connect(function()
CanDamage = true
script.Parent.blade.Touched:connect(function(p)
IsTouching = true
if IsTouching == true and CanDamage == true then
print("CanDamage has been verified")
print("Can Damage has been sent to false")
CanDamage = false
p.Parent.Humanoid:TakeDamage(20)
print("The Player has taken damage")
end
end)
script.Parent.blade.TouchEnded:connect(function()
IsTouching = false
end)
end)

3 comments
Just so you know, CanDamage is not a reference to the Value property of your CanDamage BoolValue. It will not update if the Value changes either.
ok so why is it working then and how would we get it to update it, also do you know how we would get it to stop holding onto damage.
Because the touched event is working, you can’t have the CanDamage value equal itself. To update it you could use a Changed or GetPropertyChangedSignal