I'm making a sequel to don't press the button. It's released but if you press the button at the same time or 2 or more times it makes the disasters glitch and people mess with it and messes up. The button uses a clickdetector. Here's the button's main script :
-- Programmed by Skylark011 local db = true script.Parent.ClickDetector.MouseClick:connect(function(Player) print("click") game.Workspace.lobby:Stop() print("GLOBAL SSEQ STOP") local parts = game.ServerStorage script.Parent.BrickColor = BrickColor.Red() script.Parent.clicksound:Play() script.Parent.ClickDetector.MaxActivationDistance = "0" print("math.random is running...") print("CHOOSING DISASTER") local m = math.random(1, 11) if m == 1 then if db then db = false print("math.random choosed 1.") print("OH NOES TEH TORNADO IS COMIN") parts.Tornado:Clone().Parent = game.Workspace wait(25) game.Workspace.Tornado:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") wait() db = true end end if m == 2 then if db then db = false print("math.random choosed 2.") print("AHHH METEOR! PRESSURE IS ON NOW!") parts.meteorattack:Clone().Parent = game.Workspace wait(30) game.Workspace.meteorattack:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 3 then if db then db = false print("math.random choosed 3.") print("IMA FIRIN MAH LAZER!!") parts.lazar:Clone().Parent = game.Workspace wait(4) game.Workspace.lazar:Destroy() game.Workspace.blast:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 4 then if db then db = false print("math.random choosed 4.") print("obby time!! :DDDD") game.Workspace.block1.CanCollide = false parts.obby:Clone().Parent = game.Workspace wait(60) game.Workspace.obby:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.block1.CanCollide = true game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 5 then if db then db = false print("math.random choosed 5.") print("skylark has a present!") parts.sky:Clone().Parent = game.Workspace wait(15) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 6 then if db then db = false print("math.random choosed 6.") print("RIP IDK") parts.zombieattack:Clone().Parent = game.Workspace wait(35) game.Workspace.zombieattack:Destroy() game.Workspace.Zombie:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") wait() db = true end end if m == 7 then if db then db = false print("math.random choosed 7.") print("noob song!!!111") parts.dancing:Clone().Parent = game.Workspace wait(38.2) game.Workspace.dancing:Destroy() game.Workspace.noob:Stop() game.Workspace.Disco_Light.Disabled = true game.Lighting.Ambient = Color3.new(0,0,0) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 8 then if db then db = false print("math.random choosed 8.") print("A FLOOD!! GRRGHGRGHG") parts.flood:Clone().Parent = game.Workspace wait(30) game.Workspace.flood:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 9 then if db then db = false print("math.random choosed 9.") print("jumprope time!!!!") game.Workspace.block1.CanCollide = false game.Workspace.block2.CanCollide = false game.Workspace.block3.CanCollide = false game.Workspace.block4.CanCollide = false script.Parent.Parent.Part1.CanCollide = false script.Parent.Parent.Part2.CanCollide = false script.Parent.Parent.Part3.CanCollide = false script.Parent.Parent.click.CanCollide = false parts.jumper:Clone().Parent = game.Workspace wait(40) game.Workspace.jumper:Destroy() script.Parent.Parent.Part1.CanCollide = true script.Parent.Parent.Part2.CanCollide = true script.Parent.Parent.Part3.CanCollide = true script.Parent.Parent.click.CanCollide = true game.Workspace.block1.CanCollide = true game.Workspace.block2.CanCollide = true game.Workspace.block3.CanCollide = true game.Workspace.block4.CanCollide = true script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 10 then if db then db = false print("math.random choosed 10.") print("O NOES IM FALLIN FOREVER") parts.fall:Clone().Parent = game.Workspace game.Workspace.Baseplate.CanCollide = false game.Workspace.Baseplate.Transparency = 1 wait(10) game.Workspace.fall:Destroy() game.Workspace.Baseplate.CanCollide = true game.Workspace.Baseplate.Transparency = 0 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end if m == 11 then if db then db = false print("math.random choosed 11.") print("O NOES IM FALLIN FOREVER") parts["Purple Nebula"]:Clone().Parent = game.Lighting game.Workspace.worldy:Play() game.Workspace.Gravity = 22.2 game.Workspace.Baseplate.Transparency = 1 wait(30) game.Lighting["Purple Nebula"]:Destroy() game.Workspace.worldy:Stop() game.Workspace.Baseplate.Transparency = 0 game.Workspace.Gravity = 196.2 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait() db = true end end end)
So that's the main script. I don't know what to use. I've looked on the internet but I saw nothing. Please help! Thank you Its fixed!!
What you need is a debounce, it's really simple, it doesn't let anything happen if someone presses the button more than once before you allow it.
local db = true script.Parent.ClickDetector.MouseClick:connect(function(Player) if db then db=false --your stuff if you allow a new disaster then db=true end end end)
you can either use the if you allow disaster then
if statement, or you can just wait a certain amount of time.
--after your stuff wait(10) --waits 10 seconds instead db= true
If you had done exactly what I said to do, it would've looked like this:
local db = true script.Parent.ClickDetector.MouseClick:connect(function(Player) if db then db = false print("click") game.Workspace.lobby:Stop() print("GLOBAL SSEQ STOP") local parts = game.ServerStorage script.Parent.BrickColor = BrickColor.Red() script.Parent.clicksound:Play() script.Parent.ClickDetector.MaxActivationDistance = "0" print("math.random is running...") print("CHOOSING DISASTER") local m = math.random(1, 11) if m == 1 then print("math.random choosed 1.") print("OH NOES TEH TORNADO IS COMIN") parts.Tornado:Clone().Parent = game.Workspace wait(25) game.Workspace.Tornado:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") end if m == 2 then print("math.random choosed 2.") print("AHHH METEOR! PRESSURE IS ON NOW!") parts.meteorattack:Clone().Parent = game.Workspace wait(30) game.Workspace.meteorattack:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 3 then print("math.random choosed 3.") print("IMA FIRIN MAH LAZER!!") parts.lazar:Clone().Parent = game.Workspace wait(4) game.Workspace.lazar:Destroy() game.Workspace.blast:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 4 then print("math.random choosed 4.") print("obby time!! :DDDD") game.Workspace.block1.CanCollide = false parts.obby:Clone().Parent = game.Workspace wait(60) game.Workspace.obby:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.block1.CanCollide = true game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 5 then print("math.random choosed 5.") print("skylark has a present!") parts.sky:Clone().Parent = game.Workspace wait(15) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 6 then print("math.random choosed 6.") print("RIP IDK") parts.zombieattack:Clone().Parent = game.Workspace wait(35) game.Workspace.zombieattack:Destroy() game.Workspace.Zombie:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") end if m == 7 then print("math.random choosed 7.") print("noob song!!!111") parts.dancing:Clone().Parent = game.Workspace wait(38.2) game.Workspace.dancing:Destroy() game.Workspace.noob:Stop() game.Workspace.Disco_Light.Disabled = true game.Lighting.Ambient = Color3.new(0,0,0) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 8 then print("math.random choosed 8.") print("A FLOOD!! GRRGHGRGHG") parts.flood:Clone().Parent = game.Workspace wait(30) game.Workspace.flood:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 9 then print("math.random choosed 9.") print("jumprope time!!!!") game.Workspace.block1.CanCollide = false game.Workspace.block2.CanCollide = false game.Workspace.block3.CanCollide = false game.Workspace.block4.CanCollide = false script.Parent.Parent.Part1.CanCollide = false script.Parent.Parent.Part2.CanCollide = false script.Parent.Parent.Part3.CanCollide = false script.Parent.Parent.click.CanCollide = false parts.jumper:Clone().Parent = game.Workspace wait(40) game.Workspace.jumper:Destroy() script.Parent.Parent.Part1.CanCollide = true script.Parent.Parent.Part2.CanCollide = true script.Parent.Parent.Part3.CanCollide = true script.Parent.Parent.click.CanCollide = true game.Workspace.block1.CanCollide = true game.Workspace.block2.CanCollide = true game.Workspace.block3.CanCollide = true game.Workspace.block4.CanCollide = true script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 10 then print("math.random choosed 10.") print("O NOES IM FALLIN FOREVER") parts.fall:Clone().Parent = game.Workspace game.Workspace.Baseplate.CanCollide = false game.Workspace.Baseplate.Transparency = 1 wait(10) game.Workspace.fall:Destroy() game.Workspace.Baseplate.CanCollide = true game.Workspace.Baseplate.Transparency = 0 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end if m == 11 then print("math.random choosed 11.") print("O NOES IM FALLIN FOREVER") parts["Purple Nebula"]:Clone().Parent = game.Lighting game.Workspace.worldy:Play() game.Workspace.Gravity = 22.2 game.Workspace.Baseplate.Transparency = 1 wait(30) game.Lighting["Purple Nebula"]:Destroy() game.Workspace.worldy:Stop() game.Workspace.Baseplate.Transparency = 0 game.Workspace.Gravity = 196.2 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") end wait(10) db = true end)
Attempt :
-- Programmed by Skylark011 local db = false script.Parent.ClickDetector.MouseClick:connect(function(Player) print("click") game.Workspace.lobby:Stop() print("GLOBAL SSEQ STOP") local parts = game.ServerStorage script.Parent.BrickColor = BrickColor.Red() script.Parent.clicksound:Play() script.Parent.ClickDetector.MaxActivationDistance = "0" print("math.random is running...") print("CHOOSING DISASTER") local m = math.random(1, 11) if m == 1 then if db then db = true print("math.random choosed 1.") print("OH NOES TEH TORNADO IS COMIN") parts.Tornado:Clone().Parent = game.Workspace wait(25) game.Workspace.Tornado:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") wait(10) db = false end end if m == 2 then if db then db = true print("math.random choosed 2.") print("AHHH METEOR! PRESSURE IS ON NOW!") parts.meteorattack:Clone().Parent = game.Workspace wait(30) game.Workspace.meteorattack:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 3 then if db then db = true print("math.random choosed 3.") print("IMA FIRIN MAH LAZER!!") parts.lazar:Clone().Parent = game.Workspace wait(4) game.Workspace.lazar:Destroy() game.Workspace.blast:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 4 then if db then db = true print("math.random choosed 4.") print("obby time!! :DDDD") game.Workspace.block1.CanCollide = false parts.obby:Clone().Parent = game.Workspace wait(60) game.Workspace.obby:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.block1.CanCollide = true game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 5 then if db then db = true print("math.random choosed 5.") print("skylark has a present!") parts.sky:Clone().Parent = game.Workspace wait(15) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 6 then if db then db = true print("math.random choosed 6.") print("RIP IDK") parts.zombieattack:Clone().Parent = game.Workspace wait(35) game.Workspace.zombieattack:Destroy() game.Workspace.Zombie:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() game.Lighting.Brightness = 2 print("GLOBAL SSEQ START") wait(10) db = false end end if m == 7 then if db then db = true print("math.random choosed 7.") print("noob song!!!111") parts.dancing:Clone().Parent = game.Workspace wait(38.2) game.Workspace.dancing:Destroy() game.Workspace.noob:Stop() game.Workspace.Disco_Light.Disabled = true game.Lighting.Ambient = Color3.new(0,0,0) script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 8 then if db then db = true print("math.random choosed 8.") print("A FLOOD!! GRRGHGRGHG") parts.flood:Clone().Parent = game.Workspace wait(30) game.Workspace.flood:Destroy() script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 9 then if db then db = true print("math.random choosed 9.") print("jumprope time!!!!") game.Workspace.block1.CanCollide = false game.Workspace.block2.CanCollide = false game.Workspace.block3.CanCollide = false game.Workspace.block4.CanCollide = false script.Parent.Parent.Part1.CanCollide = false script.Parent.Parent.Part2.CanCollide = false script.Parent.Parent.Part3.CanCollide = false script.Parent.Parent.click.CanCollide = false parts.jumper:Clone().Parent = game.Workspace wait(40) game.Workspace.jumper:Destroy() script.Parent.Parent.Part1.CanCollide = true script.Parent.Parent.Part2.CanCollide = true script.Parent.Parent.Part3.CanCollide = true script.Parent.Parent.click.CanCollide = true game.Workspace.block1.CanCollide = true game.Workspace.block2.CanCollide = true game.Workspace.block3.CanCollide = true game.Workspace.block4.CanCollide = true script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 10 then if db then db = true print("math.random choosed 10.") print("O NOES IM FALLIN FOREVER") parts.fall:Clone().Parent = game.Workspace game.Workspace.Baseplate.CanCollide = false game.Workspace.Baseplate.Transparency = 1 wait(10) game.Workspace.fall:Destroy() game.Workspace.Baseplate.CanCollide = true game.Workspace.Baseplate.Transparency = 0 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end if m == 11 then if db then db = true print("math.random choosed 11.") print("O NOES IM FALLIN FOREVER") parts["Purple Nebula"]:Clone().Parent = game.Lighting game.Workspace.worldy:Play() game.Workspace.Gravity = 22.2 game.Workspace.Baseplate.Transparency = 1 wait(30) game.Lighting["Purple Nebula"]:Destroy() game.Workspace.worldy:Stop() game.Workspace.Baseplate.Transparency = 0 game.Workspace.Gravity = 196.2 script.Parent.ClickDetector.MaxActivationDistance = "32" script.Parent.BrickColor = BrickColor.Green() game.Workspace.lobby:Play() print("GLOBAL SSEQ START") wait(10) db = false end end end)