I am making a “PowerOutage” System, and I am trying to make that the Script can finalizes all the Models associating in the “Lights” Folder. How would I do this?
Script:
-- PowerSystem Script
while true do
local randomnumber = wait(math.random(5, 7))
print(randomnumber)
game.Lighting.Atmosphere.Density = 1
game.Lighting.Atmosphere.Haze = 10
script.PowerOff:Play()
script.PowerOn:Play()
workspace.Lights.LightBulb.Bulb.PointLight.Brightness = 0 -- Here
workspace.Lights.LightBulb.Light.Transparency = 1 -- Here
local randomnumber = wait(math.random(9, 20))
print(randomnumber)
script.PowerOn:Play()
script.PowerOff:Stop()
workspace.Lights.LightBulb.Bulb.PointLight.Brightness = 1 -- Here
workspace.Lights.LightBulb.Light.Transparency = 0 -- Here
game.Lighting.Atmosphere.Density = 0
game.Lighting.Atmosphere.Haze = 0
end
for i, v in pairs(workspace.Lights.Folder:GetDescendants()) do -- change folder name. You can use GetChildren(), idk how your folder is organised
if v:IsA("Model") and v.Name == "InsertModelName" then -- change model name
--code
end
end
for i, v in pairs(workspace.Lights.Folder:GetDescendants()) do -- change folder name or use GetChildren(), idk how your folder is organised
if v:IsA("Model") and v.Name == "LightBulb" then -- change model name
--code
end
end
while true do
local randomnumber = wait(math.random(5, 7))
print(randomnumber)
---------------------------------------------------------------------------------
game.Lighting.Atmosphere.Density = 1
game.Lighting.Atmosphere.Haze = 10
script.PowerOff:Play()
script.PowerOn:Play()
local randomnumber = wait(math.random(9, 20))
print(randomnumber)
script.PowerOn:Play()
script.PowerOff:Stop()
workspace.Lights.LightBulb.Bulb.PointLight.Brightness = 1
workspace.Lights.LightBulb.Light.Transparency = 0
game.Lighting.Atmosphere.Density = 0
game.Lighting.Atmosphere.Haze = 0
end
for i, v in pairs(workspace.Lights:GetDescendants()) do
if v:IsA("Model") and v.Name == "LightBulb" then
while true do
local randomnumber = wait(math.random(5, 7))
print(randomnumber)
---------------------------------------------------------------------------------
game.Lighting.Atmosphere.Density = 1
game.Lighting.Atmosphere.Haze = 10
script.PowerOff:Play()
script.PowerOn:Play()
local randomnumber = wait(math.random(9, 20))
print(randomnumber)
script.PowerOn:Play()
script.PowerOff:Stop()
v.Bulb.PointLight.Brightness = 1
v.Light.Transparency = 0
game.Lighting.Atmosphere.Density = 0
game.Lighting.Atmosphere.Haze = 0
end
end
end
Blockquote ------------------------------------------------------------------------------------------------------- is where the Lighting Brightness and Transparency goes.
-- PowerSystem Script
while true do
for i, v in pairs(workspace.Lights:GetDescendants()) do
if v:IsA("Model") and v.Name == "LightBulb" then
while true do
local randomnumber = wait(math.random(5, 7))
print(randomnumber)
v.Bulb.PointLight.Brightness = 0
v.Light.Transparency = 1
game.Lighting.Atmosphere.Density = 1
game.Lighting.Atmosphere.Haze = 10
script.PowerOff:Play()
script.PowerOn:Play()
local randomnumber = wait(math.random(9, 20))
print(randomnumber)
script.PowerOn:Play()
script.PowerOff:Stop()
v.Bulb.PointLight.Brightness = 1
v.Light.Transparency = 0
game.Lighting.Atmosphere.Density = 0
game.Lighting.Atmosphere.Haze = 0
end
end
end
end