I have no idea how to change the time of day in a script. Like in some games, the time of day changes, eventually from day, it gets to the afternoon, from the afternoon, night. That's what I'm trying to do, how exactly would I change the time?
1 | local Lighting = game:GetService( "Lighting" ) |
2 |
3 | Lighting.TimeOfDay = "12:00:00" |
TimeOfDay takes a string that represents the current time in hours, minutes, and seconds. You have to concatenate the numbers together into a string when setting TimeOfDay. Here's an example script that goes from night to day to night.
01 | local Lighting = game:GetService( "Lighting" ) |
02 | local seconds = 0 |
03 |
04 | while true do |
05 | for hours = 0 , 23 do |
06 | for minutes = 0 , 59 do |
07 | wait( 0.1 ) |
08 | Lighting.TimeOfDay = tostring (hours) .. ":" .. tostring (minutes) .. ":" .. tostring (seconds) |
09 | end |
10 | end |
11 | end |