How to disable a button click?

How to temporarily avoid a button to be clicked?

2 Likes

just delete or editout the MouseButton1Click function

2 Likes

So personally I would do this by using a variable lock. I’ll display what I mean:

local button = -- whatever/wherever your button is

local disable = false -- this variable is what will lock the click function of the button
button.MouseButton1Click:Connect(function()
    if disable then return end -- if disable is true then we immediately return from this function

    -- do stuff here
end)

This is the basic format of what I would use, you can have the script set disable to true/false whenever you please.

Hope this helped!

Bubba

2 Likes

https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Click

https://developer.roblox.com/en-us/api-reference/class/GuiButton

There is everything you would need to undestand how to disable button in these websites.
Othewise you can just do a if statement like @bubbavimto proposed

2 Likes

Make the button’s visibility false.

button.Visible = false

Set the MaxActivationDistance to 0

If you wanted to be memory conscious you could disconnect the event and then reconnect it when necessary.

1 Like

That’s what I’m doing.