generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Time of day help

Previous Thread :: Next Thread 
greedyawesomeman is not online. greedyawesomeman
Joined: 18 Apr 2010
Total Posts: 1038
15 Jul 2015 06:15 PM
I'm trying to make the lights turn on/off at a certain time of day in Roblox. I have two scripts, one changes the time of day and I have one checking to see what time it is.

TOD Changer:

l = game:service("Lighting")
while true do
wait(0.1)
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight() +0.1) --almost one minute every second.
end


Checker:

l = game:service("Lighting")
currentTime = l:GetMinutesAfterMidnight()
local light = game.Workspace.LampPost1.Light.Light

while true do
wait(.1)
print(currentTime)
end

However, the check script will just keep printing the same time over and over again, I assume it's the time it starts on. Help?
Report Abuse
aliandbaheeg is not online. aliandbaheeg
Joined: 10 Jun 2014
Total Posts: 1092
15 Jul 2015 06:18 PM
The reason is because, you declared currentTime out of the loop, thus it'll stay at a constant value

to fix this, define it in the loop

l = game:service("Lighting")
local light = game.Workspace.LampPost1.Light.Light

while true do
wait(.1)
currentTime = l:GetMinutesAfterMidnight()
print(currentTime)
end


-Baheeg
Report Abuse
greedyawesomeman is not online. greedyawesomeman
Joined: 18 Apr 2010
Total Posts: 1038
15 Jul 2015 07:23 PM
Thanks! It worked!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image