Am I properly trying to make parts read game.Lighting.TimeofDay?
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
1 | minutesAfterMidnight = 0 |
3 | minutesAfterMidnight = minutesAfterMidnight + 10 |
4 | game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) |
code within each of the Light Emitting Parts
1 | lightPart = script.Parent |
2 | if game.Lighting.TimeOfDay = = "06:00:00" then |
3 | lightPart.Material = Enum.Material.Plastic |
4 | lightPart.PointLight.Enabled = false |
6 | if game.Lighting.TimeOfDay = = "18:00:00" then |
7 | lightPart.Material = Enum.Material.Neon |
8 | lightPart.PointLight.Enabled = true |
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
01 | lightPart = game.Workspace.StreetLamp.lightPart |
02 | minutesAfterMidnight = 0 |
04 | minutesAfterMidnight = minutesAfterMidnight + 10 |
05 | game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) |
08 | if game.Lighting.TimeOfDay = = "06:00:00" then |
09 | lightPart.Material = Enum.Material.Plastic |
10 | lightPart.PointLight.Enabled = false |
12 | if game.Lighting.TimeOfDay = = "18:00:00" then |
13 | lightPart.Material = Enum.Material.Neon |
14 | lightPart.PointLight.Enabled = true |
Thank you in advance for your help and feedback
~MBacon15