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

Click Detector Disable for 1 minute?

Hi there scripters out there i was wondering how to add a function when on click it immdiatly disbles the button for 1 minute before renableing it to be clicked the command should go right under sound play i need it for both thanks

function ToggleLight()

if script.Parent.ClickDetector.MaxActivationDistance == 15 then
script.Parent.OpenSound:play()
script.Parent.BrickColor = BrickColor.new("Bright red") 
game.Workspace.lockdowndoor1.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor1.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor2.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor2.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor3.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor3.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor4.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor4.Script.Disabled = false
wait(20)

script.Parent.ClickDetector.MaxActivationDistance = 15

 else
	

script.Parent.OpenSound:play()
script.Parent.BrickColor = BrickColor.new("Yellow") 
game.Workspace.lockdowndoor1.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor1.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor2.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor2.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor3.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor3.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor4.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor4.Script.Disabled = false
wait(20)

script.Parent.ClickDetector.MaxActivationDistance = 15
end
end

script.Parent.ClickDetector.MouseClick:connect(ToggleLight)

2 comments

0

Please put in code block.

0

Code block please!

2 answers

✓ Accepted answer

Because your script is not in code block and is hard to read, just add this into your script:

script.Parent.ClickDetector.MaxActivationDistance = 0
wait(60) --Wait a min
script.Parent.ClickDetector.MaxActivationDistance = 15

Pretty simple. I can't explain it now because it's pretty late. Basically it's just making the ClickDetector unclickable.



EDIT

You added a code block:

function ToggleLight()

if script.Parent.ClickDetector.MaxActivationDistance == 15 then
script.Parent.ClickDetector.MaxActivationDistance = 0 --Prevent clicking, it does it right after the player clicks.
script.Parent.OpenSound:play()
game.Workspace.lockdowndoor1.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor1.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor2.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor2.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor3.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor3.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor4.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor4.Script.Disabled = false
wait(20)

 else


script.Parent.OpenSound:play()
game.Workspace.lockdowndoor1.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor1.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor2.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor2.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor3.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor3.Script.Disabled = false
wait(20)
game.Workspace.lockdowndoor4.Script.Disabled = true
wait(.1)
game.Workspace.lockdowndoor4.Script.Disabled = false
wait(20)
script.Parent.ClickDetector.MaxActivationDistance = 15
end
end

script.Parent.ClickDetector.MouseClick:connect(ToggleLight)

1 comment

0

well it needs to be diable right away cause if its not and people click kit again the lockdown doors will be messed up and go where they arnt suppose to go

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