As most of you may know, the roblox wiki takes you through a Day/Night cycle tutorial along with a script to turn a light on and off, which works for one part.
I attempted to split both of the parts apart so that the ServerScriptStorage handles the passage of time, while each individual part handles turning itself on and off, except that the lights no longer wish to function.
Simple Day/Night code
minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 10 --value is big for the sake of debugging game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(.1) end
code within each of the Light Emitting Parts
lightPart = script.Parent if game.Lighting.TimeOfDay == "06:00:00" then lightPart.Material = Enum.Material.Plastic lightPart.PointLight.Enabled = false end if game.Lighting.TimeOfDay == "18:00:00" then lightPart.Material = Enum.Material.Neon lightPart.PointLight.Enabled = true end
Hierarchy to help understand the Parent/Child relationships in the event that that is what I messed up on.
https://gyazo.com/36021087292c35a8be3aa6580ad11215
Original combined code for Day/Night + Light on/off
lightPart = game.Workspace.StreetLamp.lightPart -- Directory for the light minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 10 --For Debugging game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(.1) if game.Lighting.TimeOfDay == "06:00:00" then lightPart.Material = Enum.Material.Plastic lightPart.PointLight.Enabled = false end if game.Lighting.TimeOfDay == "18:00:00" then lightPart.Material = Enum.Material.Neon lightPart.PointLight.Enabled = true end end
Thank you in advance for your help and feedback
~MBacon15