I made a function in sword script and its working but with one issue hitting mutiple time.
I tried to put diffrent debounces at the same time and changed many thing but still hits multiple time
--
local db1 = false
function slash(dmg, cd)
blade.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("NPCHumanoid")
if hum and not db1 then
hum:TakeDamage(dmg)
db1 = true
end
wait(cd)
db1 = false
end)
end
When you use function slash(), it creates a new blade.Touched function every single time, meaning multiple functions are firing off a single touch, making the debounce useless.
You can either disconnect the function at the end of the script or use blade.Touched:Once() which immediately disconnects the function from the event after it fires.