How to detect if the cooldown is still running or the cooldown is ended

i want to use this to the car spawner and i can’t figure how to detect if the cooldown finished or ended

you can put a print(“Cooldown over”) after the cooldown is finished in your script?

no not that,i try to make if the player still clicking before the cooldown even ended a notification appear.

im using a billboard gui

if CD == true then
– ur code here
end

OOOOOO, thank you. :slight_smile: iehfsbhs

did that work…?
i cant tell if your being sarcastic or not

1 Like

no i just figure out that i have to use this

1 Like

it does work but there is still little problem. the notification only appear when the debounce hit 10 seconds :

local replicatedStorage = game:GetService("ReplicatedStorage")
local car = replicatedStorage:WaitForChild("Car")
local debounce = false
local clickCar = script.Parent.MouseButton1Click

function notification()
	game:GetService("StarterGui"):SetCore("SendNotification", {
		Title = "Error",
		Text = "You're doing this to fast",
		Icon = "",
		Duration = "4"
	})
end

clickCar:Connect(function()
	if debounce == false then
		debounce = true
		local model = car:Clone()
		model.Parent = workspace
		wait(10)
		debounce = false
	end
	if debounce == false then
		wait(0.2)
		notification()
	end
end)

change the seccond ‘if debounce == false then’ to ‘if debounce == true then’

Please do the following instead, it’s shorter and better practice

if debounce then
-- true
end
if not debounce then
-- false
end

Edit note: And actually, the one below is better for some cases;

if debounce then return end -- if true it wont go further
-- false
if not debounce then return end  -- if false it wont go further
-- true
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.