LawMixer

MainScript

Aug 15th, 2021 (edited)
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. --[[
  2.    
  3.     This is divided into different lights, FacilityLight1, FacilityLight2, & etc;
  4.  
  5.     Once the light has changed, it finds the light, sees if its enabled or not, and if its not
  6.     then it will turn it to glass or neon depending on what it finds;
  7.  
  8.     There's another script that changes it to false and true, every randomized second.
  9. ]]
  10.  
  11.  
  12. game.ReplicatedStorage.LightStatus.Sector1.Changed:Connect(function()
  13.     for i, light in pairs(workspace:GetDescendants()) do
  14.         if light.Name == "FacilityLight1" then
  15.             wait()
  16.             light.SpotLight.Enabled = game.ReplicatedStorage.LightStatus.Sector1.Value
  17.             script.sfx:Clone().Parent = light
  18.             light.sfx:Play()
  19.             if light.SpotLight.Enabled == false then
  20.                 light.Material = "Glass"
  21.             else
  22.                 light.Material = "Neon"
  23.             end
  24.            
  25.         end
  26.     end
  27.    
  28. end)
  29. game.ReplicatedStorage.LightStatus.Sector2.Changed:Connect(function()
  30.     for i, light in pairs(workspace:GetDescendants()) do
  31.         if light.Name == "FacilityLight2" then
  32.             wait()
  33.             light.SpotLight.Enabled = game.ReplicatedStorage.LightStatus.Sector2.Value
  34.             script.sfx:Clone().Parent = light
  35.             light.sfx:Play()
  36.             if light.SpotLight.Enabled == false then
  37.                 light.Material = "Glass"
  38.             else
  39.                 light.Material = "Neon"
  40.             end
  41.         elseif light.Name == "Light_C_Q1" then
  42.             wait()
  43.             light.Bulb.SpotLight.Enabled = game.ReplicatedStorage.LightStatus.Sector2.Value
  44.             script.sfx:Clone().Parent = light.Bulb
  45.             light.Bulb.sfx:Play()
  46.             if light.Bulb.SpotLight.Enabled == false then
  47.                 light.Bulb.Material = "Glass"
  48.             else
  49.                 light.Bulb.Material = "Neon"
  50.             end
  51.            
  52.         end
  53.     end
  54. end)
  55.  
  56. game.ReplicatedStorage.LightStatus.Sector3.Changed:Connect(function()
  57.     for i, light in pairs(workspace:GetDescendants()) do
  58.         if light.Name == "FacilityLight3" then
  59.             wait()
  60.             light.SpotLight.Enabled = game.ReplicatedStorage.LightStatus.Sector3.Value
  61.             script.sfx:Clone().Parent = light
  62.             light.sfx:Play()
  63.             if light.SpotLight.Enabled == false then
  64.                 light.Material = "Glass"
  65.             else
  66.                 light.Material = "Neon"
  67.             end
  68.            
  69.         end
  70.     end
  71.    
  72. end)
Add Comment
Please, Sign In to add comment