So Im building and when I use my touch function in only works once then it stops. Is there something Im doing wrong?
My sword script for touch and damage:
script.Parent.DamagePart.Touched:Connect(function(p) if script.Parent.CanDamage.Value == true then script.Parent.CanDamage.Value = false p.Parent.Humanoid:TakeDamage(20) end end)
script.Parent.DamagePart.Touched:Connect(function(p) if script.Parent.CanDamage.Value == true then script.Parent.CanDamage.Value = false p.Parent.Humanoid:TakeDamage(20) script.Parent.CanDamage.Value = true end end)
You never set the CanDamage value back to true, so the script doesn't get the heads up to run again. You can add a wait if you want to so they don't get damaged as rapidly if you want. This will set it back to true right after the character takes the 20 damage.
Hope this helps!