Howdy, everyone!
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:
^ 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
/ Disable
a 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.