Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to disable a text button from being clickable?

I've tried debounce, i've tried locking the mouse but it can still click, and locking center could still spam the button before it locks your mouse

here's a little snip of my code:

option2.MouseButton1Click:Connect(function()
	local debounce = false
	if not debounce then 
		debounce = true
		UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		UserInputService.MouseIconEnabled = false
		option1.Parent.Enabled = false
		option3.Parent.Enabled = false
		wait(1)
		textbox.Text = "."
	wait(1)
	textbox.Text = ".."
	wait(1)
	textbox.Text = "..."
	wait(3)
	debounce = false
	option1.Parent.Enabled = true
	option3.Parent.Enabled = true
	UserInputService.MouseBehavior = Enum.MouseBehavior.Default
	UserInputService.MouseIconEnabled = true
	end
	end)

4 comments

0

There is a property of TextButton called Selected, set it to false

0

i've tried that too, it doesn't disable it from being able to be pressed twice after the code has run

0

Then maybe add that debounce and if it can do code set it to true.

0

Or if you wan't to make it looks like not selectable, Set AutoButtonColor to false and Disable code in script with debounce

1 answer

Here's how to fix it: Putting the debounce declare outside of the function will fix it. Explanition: Because you putted the debounce declare inside the function , every time you press the button it will declare a new debounce boolean varible, and it is LOCAL. So the first time the function is runned it declares a debounce that the spam times cannot see.

This discussion is preserved as it was. New answers, comments, and votes are closed.