Why wont the ClickDetector on my button show up after the script has ran?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to know how I can let players press the button for the door again.

  2. What is the issue? Include screenshots / videos if possible!
    I have made a sliding door, when a part is clicked, it will open. When it closes automatically however, it does not open again when I click it and the click detector does not show up. Did I make an error somewhere in my script? Or do I have to add something? (Note, I’m using the plugin “TweenService animator” for Tweening.)

animator = require(script.Parent.Door.Animator)

script.Parent.Button.ClickDetector.MouseClick:Connect(function()
	script.Parent.Button.ClickDetector.MaxActivationDistance = 0
	wait(0.1)
	script.Parent.Door.Open:Play()
	wait(0.1)
	animator.Door_Open:Play()
	wait(4)
	script.Parent.Door.Open:Play()
	wait(0.1)
	animator.Door_Close:Play()

end)
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I was wondering if I could try looping the script, but I feel that it would simply make the door open over and over. (Mind you, I’m not the best at scripting, so thats why I’m here.
1 Like

In your script, you’re setting the ClickDetectors MaxActivationDistance property to 0 once it’s been clicked. It doesn’t look like that is being changed back even after the door is closed once more which means that it won’t show up once you’ve clicked it once.

Once the door is completely closed, you have to set that value back to the desired MaxActivitationDistance. I believe the default is 32, correct me if I’m wrong though. Essentially, just add the following line to your code once the door is closed at the end.

	script.Parent.Button.ClickDetector.MaxActivationDistance = 32
-- If you want the MaxActivationDistance to be a different value, change the default 32 to the desired number.
1 Like

Wow, such a simple solution! Big help, thanks!

1 Like

image

Just to verify, the MaxActivationDistance property has a default value of 32.

1 Like