Hey everyone,
So currently I have a very basic attack script for when my NPC touches the player. I've tried using a simple wait(2) to see if that will slowdown the attack but I think its alittle more complicated then I realize.
I was also planning to work in an Animation later that would be effected by this cooldown.
Here is my basic Attack Script. Could anyone offer advice on how to setup a cooldown so the attack isnt a constant spam of damage?
local debounce = true
function onTouched(hit)
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce then
debounce = false
wait(20)
human.Health = human.Health - 1
end
end
script.Parent.Touched:connect(onTouched)

1 comment
Accept PhantomVisual's answer, they both are the same, but his actually provides a clear explanation.