How to disable a TextButton?

I’m making a dialogue GUI with TextButtons to press Yes or No. I want to find a way to disable TextButton to prevent it from being spammed. Any help?

Use the active function.

script.Parent.Active = false
OR
debounce function

Add a solution if this helps.

As its a dialouge I suggest using the activate feature!

4 Likes

You can solution my post if it helped!

Hes asking for a cooldown… not to delete it.

Oh I guess I didn’t read it properly lol. I saw he wanted to disable it and I just started typing right away

Just add a debounce like @PaintDevs said or just make it so it deactivates when clicked then do “wait(insert time here)” and then after that reactivate it.

I hope this helps

This is my script for a close button:

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible=false
end)

Its okay lol, it happens to all of us!

He didnt ask for a close button once again lol

Man this is the 3rd time I misread a discussion question. lol

2 Likes

I did it a few times too yesterday xd

You can use a debounce.

local debounce = false
local button = script.Parent -- for example

button.MouseButton1Click:Connect(function()
    if not debounce then -- if debounce is nil or false
        debounce = true -- set it to true in case the button is clicked again
        print('The button was pressed for the first time!')
        -- put whatever you want done only once here
    else -- if debounce is truthy (most often true but could be other things that aren't false or nil like a string or a number), you also don't need this, just a proof of concept
        print('The button has already been pressed!') -- then the button has been pressed so don't do anything
    end
end)

This wont work. You need to add a wait(time) for it to be able to be pressed again then make the debounce’s value false again.

And I already mentioned it in an upper comment.

Can I get an article for debounce functions on TextButton? Im not sure how they work and people are saying this works so I am going to try it out.

1 Like

Sure you could, but I dont see the need to, let me find one.

1 Like

Thank you. Ill go and check this out

It doesnt matter if its on text buttons or not, you can always tweak and change the code up.

You welcome, dm me if you have questions.