I'm making some outdoor lights, and they turn off just fine during the day, but I have no idea how to fix my script to make them turn off at night. I am using collectionservice to turn them on and off. This is all of my script since I'm not sure what part is going wrong. There is nothing coming up in the output log, either.
local CollectionService = game:GetService("CollectionService")
local taggedparts = CollectionService:GetTagged("Outdoor Lights")
local clocktime = game.Lighting.ClockTime
local light1 = game.Workspace.Bridge.LightPost1.Lamp.Light.PointLight
local light2 = game.Workspace.Bridge.LightPost2.Lamp.Light.PointLight
local light3 = game.Workspace.Bridge.LightPost3.Lamp.Light.PointLight
local light4 = game.Workspace.Bridge.LightPost4.Lamp.Light.PointLight
for _, taggedparts in pairs(taggedparts) do
if clocktime >= 8 and clocktime <= 18 then
light1.Enabled = false
light2.Enabled = false
light3.Enabled = false
light4.Enabled = false
elseif clocktime >= 18 and clocktime <= 8 then
print("Nighttime")
light1.Enabled = true
light2.Enabled = true
light3.Enabled = true
light4.Enabled = true
else
end
end
Thank you!

1 comment
Thank you so much! Turns out I was checking the time wrong as well as this issue, so thank you for pointing it out for me c: