I kind of have an idea of how it would work as I tried it before. I thought of getting all the children of the lamps or separating them and checking them every second so it matches the hour but I have no idea how to do it in actual script, can someone guide me?
you can do this individually like this
put lights in every part you want to light up, and disable them in properties
then put this script into each one
game.Lighting.Changed:connect(function() – runs the script when the time changes
if game.Lighting.TimeOfDay == “20:00:00” then – checks the time (20:00 would be 8 at night
script.Parent.Nameofthelight.Enabled = true – turns light on
script.Parent.Material = Enum.Material.Neon – makes it glow
if game.Lighting.TimeOfDay == “06:00:00” then – checks the time
script.Parent.Nameofthelight.Enabled = false
script.Parent.Material = Enum.Material.originalmaterial-- gets rid of glow
Might seem tedious but it’s the easiest way possible
Get all the parts that function as “light bulbs” put them in a separate folder or elsewhere, then you can just loop through them all (Mines are neon in this case)
for _, parts in pairs(workspace:WaitForChild("Map"):WaitForChild("LightParts")) do -- the LightBulbs are located in a separate folder. if parts:IsA("Part") then parts.Color = Color3.fromRGB(0, 0, 0) -- Since "white" is "bright" on neon materials we can change the color to black to simulate it being turned off. end end
If you want them to be “on” again just change the color to (255,255,255)
You can make the script easier to read if you put three backticks before and after it to keep the Studio formatting.
Also, it isn’t ideal to use
if game.Lighting.TimeOfDay == "20:00:00" because if there is a lag issue or something happens and TimeOfDay goes from 19:59:59 to 20:00:01 then the script won’t trigger the if statement. It’s better to use
if game.Lighting.TimeOfDay >= "20:00:00"
As @weakroblox35 said, if you have a lot of lights it’s better to have 1 script for all the lights and just loop through them to turn each on (enabled true) and off (enabled false) and change the Material back and forth from Neon to your starting Material.