NextYearStudios

Automatic Lighting(Old)

Feb 9th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. -- Services --
  2. local Lighting = game:GetService("Lighting")
  3.  
  4. local Workspace_LightSources = game.Workspace:GetChildren()
  5.  
  6. -- Basic Values --
  7. local Enabled_Material = Enum.Material.Neon -- Material when Source is on.
  8. local Disabled_Material = Enum.Material.SmoothPlastic -- Material when Source is off.
  9.  
  10. -- Light Sources Handler --
  11. function LightChange(Status)
  12.     if Status == true then
  13.         for _,a in pairs (Workspace_LightSources) do
  14.             if a.Name == "LightSource" then
  15.                 a.Material = Enabled_Material
  16.                 local LightChildren = a:GetChildren()
  17.                 for _,b in pairs (LightChildren) do
  18.                     if b.ClassName == "PointLight" or "SpotLight" or "SurfaceLight" then
  19.                         b.Enabled = true
  20.                     else
  21.                         return
  22.                     end
  23.                 end
  24.             end
  25.         end
  26.     elseif Status == false then
  27.         for _,a in pairs (Workspace_LightSources) do
  28.             if a.Name == "LightSource" then
  29.                 a.Material = Disabled_Material
  30.                 local LightChildren = a:GetChildren()
  31.                 for _,b in pairs (LightChildren) do
  32.                     if b.ClassName == "PointLight" or "SpotLight" or "SurfaceLight" then
  33.                         b.Enabled = false
  34.                     else
  35.                         return
  36.                     end
  37.                 end
  38.             end
  39.         end
  40.     end
  41. end
  42.  
  43. -- Automatic Lighting --
  44. while true do
  45.     wait(.1)
  46.     local MinutesAfterMidnight = game.Lighting:GetMinutesAfterMidnight()
  47.     game.Lighting:SetMinutesAfterMidnight(MinutesAfterMidnight + 10)
  48.  
  49.     if MinutesAfterMidnight > (18 * 60) or MinutesAfterMidnight < (5.5 * 60) then
  50.         LightChange(true)
  51.     elseif MinutesAfterMidnight < (18 * 60) or MinutesAfterMidnight > (5.5 * 60) then
  52.         LightChange(false)
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment