So basicly, I've been working on my prison game, but the lights for the yard won't turn off at the night. The material changes great. Here's the script:
while true do wait(5)
for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == "NeonPart" then
v.Material = "Neon"
elseif v.Name == "LightPart" then
v.SpotLight.Enabled = true
end
end
game.Lighting.TimeOfDay = "00:00:00"
game.Lighting.GlobalShadows = false
wait(5)
for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == "NeonPart" then
v.Material = "SmoothPlastic"
elseif v.Name == "LightPart" then
v.SpotLight.Enabled = false
end
end
game.Lighting.TimeOfDay = "12:00:00"
game.Lighting.GlobalShadows = true
end
Please note when giving answer, I'm still a beginner with scripting

2 comments
I'm in a hurry right now, so i'll make a quick question for you to answer: Were there any errors in the output window? It'd help if there were some errors so you can identify the problem more easily. (If you don't know where the output window is, click 'VIEW' on the tabs at the top, then click the output bar button)
I'd suggest looking into GetMinutesAfterMidnight in the wiki. I am sorry, I am in a hurry now, but I think that will put you on the right track to solving your problem.