How do i set a cooldown on a clicking function?

So, i want to set a cooldown when you click a UI button, for example, 2 seconds. How i do that? Sorry by keeping this thread very simple :+1: Thanks for responding :slight_smile:

5 Likes

Make debounce here is an example code:
local debounce = false
button.MouseButton1Click:connect(function()
if debounce == false then
debounce = true
print(“Clicked”)
wait(2)
debounce = false
end

Here is some more information on debounce if you don’t understand completely, I’m not the best at explaining. Debounce Patterns | Documentation - Roblox Creator Hub

14 Likes

Thanks for this. Been looking to figure this out!

1 Like