local isOn = true local debouce = false function on() isOn = true script.Parent.Transparency = 0 script.Parent.CanCollide = true end function off() isOn = false script.Parent.Transparency = 0.8 script.Parent.CanCollide = false wait(5) script.Parent.Transparency = 0 script.Parent.CanCollide = true end function onClicked() if isOn == true then off() else off() end end script.Parent.ClickDetector.MouseClick:connect(onClicked) on()
IsOn is already a debounce, there is no sense yet one to add. Debounce can also be changed, in other words IsOn is a debounce. Ok, because you want it (even if you usually only have to change your debounce to its place) I will help you:
local debounce = false function onClicked() if debounce == false then script.Parent.Transparency = 0 script.Parent.CanCollide = true wait(2.5) debounce = true else script.Parent.Transparency = 0.8 script.Parent.CanCollide = false wait(2.5) debounce = false end end script.Parent.ClickDetector.MouseClick:connect(onClicked)