ClickDetector.Disabled

Howdy, everyone! :cowboy_hat_face:

At the moment, we have a lot of things and functions to use for the ClickDetector property as it is beneficial when it comes to clicking things on any instance that can be interacted by a player. Those things being opening a gate, making things unanchored, and possibly opening up UI, but what if we wanted to do disable/enable the ClickDetector when clicked or just randomly?

Anyway, something similar to disabling scripts when disabling and enabling after some time from another Instance like ClickDetector or MouseButton1Click at most but the ability to disable ClickDetector when it is clicked is something me and most developers would agree on and personally use this as a shorter Alias or line when it comes to things like these.

local Gate = game.Workspace.Gate
local Click = script.Parent
local Gate1 = game.Workspace.Gate1

Click.ClickDetector.MouseClick:Connect(function(clicked)
	Gate:Destroy()
	script.Parent.ClickDetector:Destroy()
    print("Clicked!")	

	wait(5)
	
	local NewClick = Instance.new("ClickDetector")
	NewClick.Name = "NewDetector"
	NewClick.MaxActivationDistance = 50
	NewClick.Parent = script.Parent
	

	Gate1:Destroy()
	NewClick:Destroy()
    print("Clickedx2!")	
end)

With the code above, it seems easy but having to create and new Instance and use more functions and stuff might be a pain when you might have multiple people in a game who could use this badly, something like this would be easier to have:

local Gate = game.Workspace.Gate
local Click = script.Parent

Click.ClickDetector.MouseClick:Connect(function(clicked)
	Gate:Destroy()
	script.Parent.ClickDetector.Disabled = true

    wait(5)

    script.Parent.ClickDetector.Disabled = false
end)

For the code above me, it will become much easier and flexible to use and when it comes to situations like these, for example, you could use ClickDetector.Disabled so then after some more commands and after a wait(5), you can make sure that ClickDetector.Disabled = true would happen instead of Destroy and Instances being cloned and made constantly with a lot of scripts.

Image:

image

^ Somewhere in the properties tab, a Disable section would be there like aways when it comes to ideas like these. O_O

Having something like ClickDetector.Disabled would be pretty handy to add and use when it comes to many users inside a game or testing purposes and using :Destroy() and Instance.new() often wouldn’t help me a lot. Yes it’s nice scripting practice and usage of it is great, but having ClickDetector.Disable / Disablea property and function to use would be something I would prefer than having to loop and creating new ClickDetector every single time.

Overall, if Roblox would be able to add this into their Engine it would become very useful for me and other developers out there because it will become easy to disable and enable my ClickDetector when inside a loop for on a function as most of the reasons stated above with more Instances and Cloning, sorry if I might repeated myself on reasons, but having things like these are beneficial to development and scripting.

23 Likes

I like this idea.

Here’s something for you in the mean time while waiting:

  • You can parent the ClickDector to nil then set it back
  • You can set MaxActivationDistance = 0 then set it back

which ever you prefer to do for the Debounce

13 Likes

That’s something I would like to use as an alternative way to make ClickDetector disabled, might use that until something like ClickDetector.Disabled is something in Lua.

^ Still would prefer having a Disabled command/setting for this.

2 Likes

Setting MaxActivationDistance to 0 already does what you want, there is really no difference between that and MaxActivationDistance = 0.

6 Likes

Agree, having MaxActivationDistance to nil/0 is still a viable thing to do to make sure the ClickDetector isn’t pressable/clicked by anyone. Yet again, I would still prefer something like this as might scripters or users might not know a solution or idea that you’ve suggested.

There is somewhat of a difference between ClickDetector.Disabled and MaxActivationDistance, but I’ll take your opinion on using it.

1 Like

I am pretty sure that logically, if the maximum activation distance is set to 0 then you logically won’t be able to click it as you can’t naturally be 0 studs away from something.

7 Likes