Yes, I know this probably sounds like a really stupid question, but I just can’t figure it out. I need to disable clicking on a button for a brief period of time, and everywhere I searched, I was told to disable the Active property, but it doesn’t change anything. I looked through all the other properties as well and none of them helped. Is there something I’m missing, or is there an extra step?
game.startergui.screengui.textbutton.enabled = false
Enabled isn’t a property. I thought Active was its equivalent, but I guess not.
oh sorry game.startergui.screengui.textbutton.active = false
why would you exactly need to disable a button?
is this for a local script or something?
With the button, I want you to click on it, and then it’ll be inactive until something finishes. Kind of like a cooldown, but I need to apply this to 3 different buttons at once so that they don’t interfere with the process that was triggered when the button was initially clicked.
Like a debounce? Adding a debounce the .active
you can just do this
local Enabled = true
local TimedOutTime = 5
local Button = script.Parent.Button -- Instance of a button
Button.MouseButton1Up:Connect(function()
if Enabled == true then
Enabled = false
task.spawn(function()
local Time = 0
repeat
task.wait(0.5)
Time = Time + 0.5
until TimedOutTime < Time or TimedOutTime == Time
Enabled = true
end)
print("Clicked")
else
print("Unable to click")
end
end)
I have a cooldown system in each separate script, but I was wondering if I could apply that cooldown concept to multiple buttons in different folders
can you show me your explorer to see how you are trying to make this?
let me try to make a function that has a cooldown on each button you call it to
I have not tested this yet but you can try.
If you want a example of how to use it them tell me to
function DisableButton(Button,Function,Prints:boolean,TimedOutTime:number,FailedFunction)
local Enabled = true
Button.MouseButton1Up:Connect(function()
if Enabled == true then
Enabled = false
task.spawn(function()
local Time = 0
repeat
task.wait(0.5)
Time = Time + 0.5
until TimedOutTime < Time or TimedOutTime == Time
Enabled = true
end)
if Prints == true then
print("Clicked")
end
Function()
else
if Prints == true then
print("Clicked on delay")
end
FailedFunction()
end
end)
end
Edit : i have tested it and it seems to work fine
If I understood this correctly then you could just do something like
local ButtonOne = -- ButtonOne location
local ButtonTwo = -- ButtonTwo location
local ButtonThree = -- ButtonThree location
local LastTime = os.Time()
local DebounceTime = 5
script.Parent.MouseButton1Click:Connect(function()
if os.Time() - LastTime >= DebounceTime then
-- Your code here
ButtonOne.Active = false
ButtonTwo.Active = false
ButtonThree.Active = false
LastTime = os.time()
else
print("Cant be clicked yet")
end
end)
I didnt test this but should work, unless I made any spelling mistakes
You could use one central ModuleScript to handling all that
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.