177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 10 Feb 2016 03:48 PM |
lightPart = game.Workspace.LightPart minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 10 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
The script above makes all parts named "LightPart" turn neon at night. Although, when I put it into workspace, it only makes 1 part named "LightPart" become neon at the night. The others do not.
Does anybody know what could be causing this? |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2016 03:55 PM |
| I could be wrong, but it's probably because the variable lightPart only refers to one brick in workspace name LightPart. |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2016 03:57 PM |
No, hon, this just does the single one. You'll need a loop:
minutesAfterMidnight = 0 while true do minutesAfterMidnight = minutesAfterMidnight + 10 game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) wait(.1) local setting = (game.Lighting.TimeOfDay=='06:00:00' and 'm') or (game.Lighting.TimeOfDay=='18:00:00' and 'n') if setting then for _,v in next,workspace:GetChildren() do if v.Name=='LightPart' then v.Material = setting=='n' and 'Neon' or 'Plastic' v.PointLight.Enabled = setting=='n' and true or false end end end |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 10 Feb 2016 03:58 PM |
| Alright. Thanks, I'll see what I can do. |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 12 Feb 2016 08:59 AM |
@phoenix
I can't get your script to work. Not sure why. |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 12 Feb 2016 09:10 AM |
| Hmm can anyone edit the original script to make it affect multiple parts with the name "LightPart?" |
|
|
| Report Abuse |
|
|
222304
|
  |
 |
| Joined: 26 May 2008 |
| Total Posts: 24900 |
|
|
| 12 Feb 2016 09:35 AM |
you could try using GetChildren()
http://wiki.roblox.com/index.php?title=API:Class/Instance/GetChildren |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 12 Feb 2016 09:44 AM |
| Hmm, alright. This will help. |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
|
| 12 Feb 2016 09:55 AM |
| Ok so I tried getchildren, and all it did was switch the window that changes color/material, its still only one. |
|
|
| Report Abuse |
|
|
177117
|
  |
| Joined: 17 May 2010 |
| Total Posts: 1366 |
|
| |
|