Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with lighting script?

Asked by 10 years ago

Ok so I have this script that turns the lights on and off. I want to know what to put into the script to make it so that the lights fade off when I press it and fade on when I press it again.

Here is the script...

local P = script.Parent.Parent
local LP1 = P.Light12.Light.SpotLight
local LP2 = P.Light11.Light.SpotLight
local LP3 = P.Light10.Light.SpotLight
local LP4 = P.Light9.Light.SpotLight
local LP5 = P.Light8.Light.SpotLight
local LP6 = P.Light7.Light.SpotLight
local LP7 = P.Light6.Light.SpotLight
local LP8 = P.Light5.Light.SpotLight
local LP9 = P.Light4.Light.SpotLight
local LP10 = P.Light3.Light.SpotLight
local LP11 = P.Light2.Light.SpotLight
local LP12 = P.Light1.Light.SpotLight
local LP13 = P.Light13.Light.SpotLight
local LP14 = P.Light14.Light.SpotLight
local LP15 = P.Light15.Light.SpotLight
local LP16 = P.Light16.Light.SpotLight
local LP17 = P.Light17.Light.SpotLight
local LP18 = P.Light18.Light.SpotLight
local LP19 = P.Light19.Light.SpotLight
local LP20 = P.Light20.Light.SpotLight
local LP21 = P.Light21.Light.SpotLight
local LP22 = P.Light22.Light.SpotLight
local LP23 = P.Light23.Light.SpotLight
lp = {LP1, LP2, LP3, LP4, LP5, LP6, LP7, LP8, LP9, LP10, LP11, LP12, LP13, LP14, LP15, LP16, LP17, LP18, LP19, LP20, LP21, LP22, LP23}
btn = script.Parent.ClickDetector

function onClick()
    for i, v in pairs(lp) do
   if v.Brightness == 0 then
      while v.Brightness < 1 do
         v.Brightness = v.Brightness + 0.1
         wait()
      end
   else
      while v.Brightness > 0 do
         v.Brightness = v.Brightness - 0.1
         wait()
      end
 end

    end
end

btn.MouseClick:connect(onClick)

Answer this question