RoboX790
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 285 |
|
|
| 29 Aug 2013 11:00 AM |
It's a light on/off script but it's automated here is the script you can understand it clearly:
while true do if game.Lighting.TimeOfDay = 08:00:00 then --Lights off at this time. script.Parent.1.SpotLight.Enabled = false script.Parent.2.SpotLight.Enabled = false script.Parent.3.SpotLight.Enabled = false script.Parent.4.SpotLight.Enabled = false if game.Lighting.TimeOfDay = 17:30:00 then --Lights on at this time script.Parent.1.SpotLight.Enabled = true script.Parent.2.SpotLight.Enabled = true script.Parent.3.SpotLight.Enabled = true script.Parent.4.SpotLight.Enabled = true end --Ending the three lines end end
Output: 20:55:01.355 - Workspace.Light.Script:2: 'then' expected near '='
Any Help? :( |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:11 AM |
= 08:00:00 then
you are setting the time to that.....also don't do it like that T_T == is comparator do this :P
game.Lighting:GetMinutesAfterMidnight() > 480 then --8:00 :P |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:19 AM |
Or just do:
if game.Lighting.TimeOfDay = "18:00:00" then end |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:21 AM |
Umm you forget.....
= is setting the left side value to the right side == is comparing the left side value to the right side since if this script is VERY good at firing when it is exactly 18:00:00...== could work...but just use mine for simplicity :P |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:25 AM |
| Oops, yeah, typo. Should be double equal signs. Also, you need a wait of some sort. The script you have here will crash the game. |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:27 AM |
| Also, you're missing an end, and the second if will never fire because it's listed under the first condition in which it can't be both at the same time. To fix both problems, add an end before the second if, or change the second if to an elseif. |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2013 11:27 AM |
| Regard the missing end. You should either move one of the ends before the second if statement, or change it to an elseif. |
|
|
| Report Abuse |
|
|
RoboX790
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 285 |
|
|
| 29 Aug 2013 12:11 PM |
| Okay thanks for the help :) |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:34 PM |
| You only need one wait if you don't have like a thousand other scripts with while loops |
|
|
| Report Abuse |
|
|
Ludici
|
  |
| Joined: 22 Jul 2013 |
| Total Posts: 640 |
|
|
| 29 Aug 2013 12:38 PM |
What they are saying is true. But if you have a day/night script, I'm pretty sure that you should change the ='s to >=
~Make the simple, amazing~ |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:41 PM |
| I just do wait(0.000000001) |
|
|
| Report Abuse |
|
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:42 PM |
| But for this script wouldn't it be better to waitforchange? |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:45 PM |
I just got up this morning and haven't finished my coffee okay And .Changed would still be better than a while loop |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:53 PM |
function light() if game.Lighting.TimeOfDay=="18:00:00" then print("yes") else print("nope") end end game.Lighting.Changed:connect(light)
That way it doesn't have to be constantly looping |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 12:58 PM |
It doesn't have to be TimeOfDay.Value because it can just check every time the time changes since TOD is in Lighting. And that's why I have the "if" there. |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 01:04 PM |
It doesn't matter because MY SCRIPT WORKS |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 29 Aug 2013 01:31 PM |
| What do you want me to do, make a video and upload it to youtube just to prove it? It works find for me, you must be copying something wrong. |
|
|
| Report Abuse |
|
|
xxBsFxx
|
  |
| Joined: 26 Aug 2013 |
| Total Posts: 3281 |
|
| |
|