I want to add a cooldown to a tool so it cannot be spammed.
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() script.Parent.Input:FireServer('Mouse1', true, mouse.Hit) end) end)
The most common form of cooldown of this type is usually called a debounce, which is actually fairly easy to implement once you learn about it.
local debounce = true script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() if debounce == true then debounce = false script.Parent.Input:FireServer('Mouse1', true, mouse.Hit) wait(1)--put the cooldown you want here debounce = true end end) end)
When the script is called, it checks if the debounce is true, if it is then you set the debounce to false, go through with whatever code you want, wait a time, then set it back to true. This makes it so that it can't activate again until debounce is set back to true.