|
| 10 Nov 2013 12:41 PM |
This script is supposed to make it night in 5 seconds, turn on all the lights, then 5 seconds later, it's day and the lights turn off. But, instead: It waits 5 seconds, both 'StreetLamp''s turn on, and only one 'BuildingLight' turns on. It waits 5 seconds, it becomes day, but then the BuildingLight that didn't turn on, turns on, 5 seconds later, that BuildingLight turns off, then 5 seconds later, it turns night and loops. Here's the script:
while true do wait(5) game.Lighting.TimeOfDay = "00:00:00" for i,v in pairs(workspace:GetChildren()) do if v.Name == "StreetLamp" then v.Part1.PointLight.Enabled = true elseif v.Name == "BuildingLight" then v.PointLight.Enabled = true
wait(5) game.Lighting.TimeOfDay = "14:00:00" for i,v in pairs(workspace:GetChildren()) do if v.Name == "StreetLamp" then v.Part1.PointLight.Enabled = false elseif v.Name == "BuildingLight" then v.PointLight.Enabled = false end end end end wait() end |
|
|
| Report Abuse |
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 10 Nov 2013 12:44 PM |
Sounds like someone doesn't indent their code. If you had, you probably would notice that you're second 'wait(5)' is underneath the 'elseif v.Name == "BuildingLight" then' bit. Therefore, as soon as your code finds 1 part named BuildingLight, it's going to change to day and turn off all the things. Here's the fixed script. (I didn't change any words, just shifted lines around) while true do wait(5) game.Lighting.TimeOfDay = "00:00:00" for i,v in pairs(workspace:GetChildren()) do if v.Name == "StreetLamp" then v.Part1.PointLight.Enabled = true elseif v.Name == "BuildingLight" then v.PointLight.Enabled = true end end wait(5) game.Lighting.TimeOfDay = "14:00:00" for i,v in pairs(workspace:GetChildren()) do if v.Name == "StreetLamp" then v.Part1.PointLight.Enabled = false elseif v.Name == "BuildingLight" then v.PointLight.Enabled = false end end wait() end
|
|
|
| Report Abuse |
|
|
| 10 Nov 2013 12:48 PM |
| Sorry, I'm a total beginner. Your script works, thanks so much! |
|
|
| Report Abuse |
|