Advertisement
oopsrainbow4

Switch Lights

Feb 11th, 2023
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. -- This is main part of switch Lights script so you use many ways to call it like function, while true do, click detector, proximity prompt, etc.
  2.  
  3. local lightFolder = workspace.Lights
  4. local lights = lightFolder:GetChildren() -- Get Lights in Folder
  5.  
  6. for i_, lightBulb in ipairs(lights) do
  7.     local spotLight = lightBulb:FindFirstChildWhichIsA("SpotLight") -- To get all spotLight in each Lights
  8.    
  9.     if spotLight and not spotLight.Enabled then -- Check if SpotLight is not enabled
  10.         spotLight.Enabled = true
  11.         lightBulb.Material = Enum.Material.Neon
  12.  
  13.     elseif spotLight and spotLight.Enabled then -- Check if SpotLight is enabled
  14.         spotLight.Enabled = false
  15.         lightBulb.Material = Enum.Material.Glass
  16.     end
  17. end
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement