I am currently working on a sword right now and everything is going perfectly, but my sword only does damage once when I swing my sword. If my swing my sword again, it would stop damaging. I have a BoolValue that is set as a debounce, and the debounce works perfectly fine. When the debounce is true, it is able to do damage, if it's false, then it doesn't. I make it where it defaults as true first, but right after it does damage, it is set to false, but after one second, it is set back to true, and since it's true, it should be able to do damage again, but it doesn't. Someone, please explain why and how to fix it. Thanks!
Local Script:
local CanAttack = true
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local idle = char:WaitForChild("Humanoid"):LoadAnimation(script.idle)
local attack = char:WaitForChild("Humanoid"):LoadAnimation(script.attack)
script.Parent.Equipped:Connect(function()
idle:Play()
script.Parent.Activated:Connect(function()
if CanAttack then
idle:Stop()
attack:Play()
CanAttack = false
wait(1)
attack:Stop()
idle:Play()
CanAttack = true
script.Parent.CanDamage.Value = true
end
end)
end)
script.Parent.Unequipped:Connect(function()
idle:Stop()
end)
Script:
script.Parent.Activated:Connect(function()
script.Parent.blade.Touched:Connect(function(p)
if script.Parent.CanDamage.Value == true then
p.Parent.Humanoid:TakeDamage(20)
script.Parent.CanDamage.Value = false
end
end)
end)

3 comments
Please dont repeat questions
Because you set the CanDamage value back to true on the client. Due to filtering, it'll only show on the client
I recommend a remote event to set it back