LawMixer

I need somebody to help me with this script that I am trying to get it randomize whenever the power goes out.

Sep 17th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. local online = script.Parent.Online
  2. local broken = script.Parent.broken
  3.  
  4. local techteam = game.Teams["Manufacturing Department"]
  5.  
  6. local debounce = false
  7. local model = script.Parent.Parent
  8. local humsound = model.Body.Sound
  9. local sector = model.Name
  10. local alarm = model.Status.Alarm
  11. local function setbroken(state)
  12. if state == true then
  13. if model.Debris.Transparency == 1 then
  14. model.Debris.Sound:Play()
  15. model.Debris.Transparency = 0
  16. model.Debris.Smoke.Enabled = true
  17. model.Debris.Sparkles.Enabled = true
  18. model.Debris.ClickDetector.MaxActivationDistance = 10
  19. -------------
  20. model.Panel.Transparency = 1
  21. end
  22. else
  23.  
  24. model.Debris.Transparency = 1
  25. model.Debris.ClickDetector.MaxActivationDistance = 0
  26. model.Debris.Smoke.Enabled = false
  27. model.Debris.Sparkles.Enabled = false
  28. -------------
  29. model.Panel.Transparency = 0
  30. end
  31. end
  32. local function update()
  33. setbroken(broken.Value)
  34. if broken.Value == true then
  35. online.Value = false
  36. end
  37. game.ReplicatedStorage.LightStatus:FindFirstChild(sector).Value = online.Value
  38. if online.Value == true then
  39.  
  40. humsound:Play()
  41. alarm:Stop()
  42. model.Status.BrickColor = BrickColor.new("Lime green")
  43. elseif broken.Value == true then
  44. humsound:Stop()
  45. alarm:Play()
  46. model.Status.BrickColor = BrickColor.new("Bright yellow")
  47. else
  48. humsound:Stop()
  49. alarm:Stop()
  50. model.Status.BrickColor = BrickColor.new("Really red")
  51. end
  52. end
  53.  
  54. model.Screen.ClickDetector.MouseClick:Connect(function(plr)
  55. if debounce == true then
  56. return
  57. end
  58. debounce = true
  59. if broken.Value == true then
  60. return
  61. end
  62.  
  63. ------------
  64. if plr.Team == techteam then
  65. online.Value = not online.Value
  66. model.Status.Sound:Play()
  67. update()
  68. wait(5)
  69. end
  70. debounce = false
  71. end)
  72. wait(0.2)
  73. update()
  74.  
  75. broken.Changed:Connect(function()
  76. update()
  77. end)
  78.  
  79. model.Debris.ClickDetector.MouseClick:Connect(function(plr)
  80. for i, box in pairs(workspace.Fusebox:GetChildren()) do
  81. if box.Name == model.Name then
  82. if box.Broken.Value == true then
  83. print("fuseboxes still broken")
  84. return
  85. end
  86. end
  87. end
  88. if plr.Team == techteam then
  89. if broken.Value == true then
  90. broken.Value = false
  91. end
  92. end
  93. end)
  94.  
  95. while true do
  96. wait(1)
  97. for i, box in pairs(workspace.Fusebox:GetChildren()) do
  98. if box.Name == model.Name then
  99. if box.Broken.Value == true and broken.Value == false then
  100. print("Found broken box")
  101. broken.Value = true
  102. end
  103. end
  104. end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment