Hello everyone! I'm not a professional at scripting so I have bumped into a problem that I've been having a hard time fixing. I've been trying to script a 'punch' ability in the form of a tool. So, it went pretty well until I stumbled into a problem. Whenever it activates, it will continue dealing damage forever. I will be happy if someone comes and corrects my mistake or gives me some form of help!
script.Parent.Activated:Connect(function()
local Debounce = false
print("active")
script.Parent.Handle.Touched:Connect(function(hit)
if Debounce == false then
Debounce = true
print("something touched me!")
wait(2)
Debounce = false
end
end)

2 comments
Why are you connecting functions inside of functions
Is that bad? I'm trying to make it so the touched function only works while the tool has been activated.