local mouse=game.Players.LocalPlayer:GetMouse() local fire = script.Parent:WaitForChild('fire') local debounce = true mouse.Button1Down:connect(function(key) fire:FireServer() wait(1) debounce = false
end)
this is my script but there is no cooldown
local mouse=game.Players.LocalPlayer:GetMouse() local fire = script.Parent:WaitForChild('fire') local debounce = true mouse.Button1Down:connect(function(key) fire:FireServer() wait(1) debounce = false
end)
this is my script but there is no cooldown
Replace your script with the following:
local mouse=game.Players.LocalPlayer:GetMouse()
local fire = script.Parent:WaitForChild('fire')
local debounce = true
mouse.Button1Down:connect(function(key)
if debounce == true then
debounce = false
fire:FireServer()
wait(1)
debounce = true
end
end)
So what's wrong is that your script never checks if the debounce is true or false. So it just executes the code without cooldowns. The script I have given you will run the function only if debounce is true. As you can see, the debounce remains false for 1 second as a cooldown, and then turns true again.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thank you very much :)