Close = script.Parent Open = script.Parent.Parent.OpenButton function onClicked() Open.Transparency = 1 Open.CanCollide = false Open.ClickDetetctor.MaxActivationDistance = 0 Close.Transparency = 0 Close.CanCollide = true Close.ClickDetector.MaxActivationDistance = 12 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
How do I make the script change the MaxActivationDistance of a ClickDetector?
The code looks mostly good, but there is one small error.
Line 9: Open.ClickDetetctor.MaxActivationDistance = 0
If you look closely, you will see that ClickDetector is spelled incorrectly. Other than that, the code looks fine. Just be careful that you spell everything correctly when coding. Here is the fixed code:
Close = script.Parent Open = script.Parent.Parent.OpenButton function onClicked() Open.Transparency = 1 Open.CanCollide = false Open.ClickDetector.MaxActivationDistance = 0 Close.Transparency = 0 Close.CanCollide = true Close.ClickDetector.MaxActivationDistance = 12 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
I hope this helps!
Nothing looks wrong with this script. Just make sure that the paths are all led to the correct object. I'm not sure what else would be the problem.
PLEASE give us what 'Open' and 'Close' would equal. Like 'Open = TextButton' 'Close = Part'
Theres a couple problems
ERRORS
if 'Close' = 'Model' then line 08 is a error due to you cant see a model. I would say 'Close' = 'Part' from the script but anyways. ...
Your word ClickDetector Is typed incorrect.
Close = script.Parent -- I am guessing this is a Part Open = script.Parent.Parent.OpenButton -- Hoping this is a Part with it named OpenButton... (With a ClickDetector in it) :/ function onClicked() Close.Transparency = 1 Close.CanCollide = false Open.ClickDetector.MaxActivationDistance = 0 -- Add a wait(2) here due do it will open/close with like 0.0015th of a second. Close.Transparency = 0 Close.CanCollide = true Open.ClickDetector.MaxActivationDistance = 12 end Open.ClickDetector.MouseClick:connect(onClicked)