Advertisement
Guest User

Untitled

a guest
Jul 14th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. -- doors
  2. local model = Workspace
  3. local dArray = {
  4.     model.Door1,
  5.     model.Door2,
  6.     model.Door3,
  7.     model.Door4,
  8. }
  9.  
  10. -- windows
  11. local wArray = {
  12.     model.Window1,
  13.     model.Window2,
  14.     model.Window3,
  15.     model.Window4,
  16.     model.Window5,
  17.     model.Window6,
  18.     model.Window7,
  19. }
  20.  
  21. -- cd etc.
  22. local button = script.Parent
  23. local cd = button.ClickDetector
  24.  
  25. local wc = nil
  26. local wt = nil
  27.  
  28. local dc = nil
  29. local dt = nil
  30.  
  31. local deb = false
  32.  
  33. function shutter(brick)
  34.     wc = brick.BrickColor
  35.     wt = brick.Transparency
  36.     brick.BrickColor = BrickColor.DarkGray()
  37.     brick.Transparency = 0
  38. end
  39.  
  40. function unshutter(brick)
  41.     brick.BrickColor = wc
  42.     brick.Transparency = wt
  43. end
  44.  
  45. function lockdoors(door)
  46.     dc = door.Left.BrickColor
  47.     dt = door.Left.Transparency
  48.     door.Left.BrickColor = BrickColor.DarkGray()
  49.     door.Right.BrickColor = BrickColor.DarkGray()
  50.     door.Left.Transparency = 0
  51.     door.Right.Transparency = 0
  52.     door.Sensor.Script.Disabled = true
  53. end
  54.  
  55. function unlockdoors(door)
  56.     door.Left.BrickColor = dc
  57.     door.Right.BrickColor = dc
  58.     door.Left.Transparency = dt
  59.     door.Right.Transparency = dt
  60.     door.Sensor.Script.Disabled = false
  61. end
  62.  
  63. function lock()
  64.     _G.offb_ms_off()
  65.     wait(0.1)
  66.     _G.offb_ms_on("LOCKDOWN ACTIVATED!")
  67.    
  68.     -- shutter windows
  69.     local wCounts = 0
  70.     while wCounts < #wArray do
  71.         wCounts = wCounts + 1
  72.         shutter(wArray[wCounts])
  73.     end
  74.    
  75.     -- lock doors
  76.     local dCounts = 0
  77.     while dCounts < #dArray do
  78.         dCounts = dCounts + 1
  79.         lockdoors(dArray[dCounts])
  80.     end
  81. end
  82.  
  83. function unlock()
  84.     _G.offb_ms_off()
  85.     wait(0.1)
  86.     -- unshutter windows
  87.     local wCounts = 0
  88.     while wCounts < #wArray do
  89.         wCounts = wCounts + 1
  90.         unshutter(wArray[wCounts])
  91.     end
  92.  
  93.     -- unlock doors
  94.     local dCounts = 0
  95.     while dCounts < #dArray do
  96.         dCounts = dCounts + 1
  97.         unlockdoors(dArray[dCounts])
  98.     end
  99. end
  100.  
  101. local usedbefore = false
  102. active = false
  103.  
  104. cd.MouseClick:connect(function()
  105.     if deb ~= true then
  106.         deb = true
  107.         if usedbefore == false then
  108.             usedbefore = true
  109.             active = true
  110.             lock()
  111.             button.BrickColor = BrickColor.Red()
  112.         else
  113.             if active == true then
  114.                 active = false
  115.                 unlock()
  116.                 button.BrickColor = BrickColor.Green()
  117.             else
  118.                 active = true
  119.                 lock()
  120.                 button.BrickColor = BrickColor.Red()
  121.             end
  122.         end
  123.         wait(2)
  124.         deb = false
  125.     end
  126. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement