I made a Sword script and it does work, but only if you click long enough. if you click fast, it sometimes doesn’t damage the dummy. Can someone help me?
Here is the code
local Sword = script.Parent
local canDamage = true
local Debounce = 0.7
local isActivated = false
local function damage()
Sword.Handle.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum and canDamage then
if isActivated then
canDamage = false
hum.Health = hum.Health - 10
Sword.Deactivated:Connect(function()
wait(Debounce)
canDamage = true
end)
else return end
end
end)
end
Sword.Activated:Connect(function()
isActivated = true
print("Activated_"..tostring(isActivated))
Sword.Deactivated:Connect(function()
isActivated = false
print("Activated_"..tostring(isActivated))
end)
end)
damage()
Here is a video of what I mean.
robloxapp-20200728-1243394_Trim.wmv (510.0 KB)