Following the Day/Night cycle tutorial, I decided to separate the statements that operate the Lamps from turning on and off depending on the day and the statements that cycles through Day and Night.
When I did that, the script doesn't work at all but it shows no error, there is nothing inside Script Performance either so I know it's not running.
The script is inside a part called "Lightpart" along with another child called "PointLight" which is a PointLight. The parent of Lightpart is a Model.
Lamp Operator... (Code that doesn't work)
if game.Lighting:GetMinutesAfterMidnight() == 18 * 60 then
wait(1)
script.Parent.Material = Enum.Material.Neon
wait(1)
script.Parent.PointLight.Enabled = true
end
if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then
wait(1)
script.Parent.Material = Enum.Material.Plastic
wait(1)
script.Parent.PointLight.Enabled = false
end
Day/Night cycle... (Code that works)
lightPart = game.Workspace.Model.Lightpart
minutesafterMidnight = 0
while true do
minutesafterMidnight = minutesafterMidnight + 5
game.Lighting:SetMinutesAfterMidnight(minutesafterMidnight)
wait(.1)
end
As for why I chose to separate those two codes, it's because I notice that the codes do not run independently from each other so whenever I add in a debounce in the Lamp Operator, the Day/Night cycle stops for that rebound to.

1 comment
Is the first code on a loop, and why is it missing an end? Are the two code snippets in the same script, if so, while loops will stop the rest of the code from running because a script, unless used with certain methods, will essentially only do one thing at a time.