Im trying to make a script that makes multiple parts turn and off during a day/night cycle, and I added collection service to tag the parts. I used the tag editor plugin and it still doesnt seem to work. I keep getting the error message "ServerScriptService.Script:14: attempt to index nil with 'Enabled'. The script is located in server script service, here it is:
local lighting = game:GetService("Lighting")
local currenttime = 4
local collectionService = game:GetService("CollectionService")
local Lamps = collectionService:GetTagged("Lamps")
while true do
lighting.ClockTime = currenttime
if (currenttime >= 6 and currenttime <= 19) then
Lamps.Material = Enum.Material.Plastic
Lamps.PointLight.Enabled = false
else
Lamps.Material = Enum.Material.Neon
Lamps.PointLight.Enabled = true
end
currenttime += .01
if currenttime >= 24 then
currentTime = 0
end
wait()
end
