I want to make my own Day/Night cycle, but I don't want to have to type each individual number I want it to. I can just make something like:
1 | game.Lighting.TimeofDay |
and then I could make it to where the time increases by 0:00:10 every second.
This is probably going to be really slow, but you can adjust the wait time and how much the clocktime will increase, to your liking.
1 | local Lighting = game:GetService( 'Lighting' ) |
2 |
3 | while wait( 1 ) do |
4 | Lighting.ClockTime = Lighting.ClockTime + . 1 |
5 | end |
There are many of these out there however I'll explain how they work. You could do it two ways, using a while loop or an until loop. I would use a while loop for this because it looks like you want this cycle to go forever.
To do this while loop you would do something like this:
1 | while true do -- setting the middle part to true, essentially means it will go on forever. |
2 | --put whatever you want to happen, here. |
3 | wait() -- always have a wait inside loops unless there is an end to the loop like a for loop. |
4 | end |
In your case you would want to do:
1 | while true do |
2 | game:GetService( "Lighting" ):SetMinutesAfterMidnight(game:GetService( "Lighting" ):SetMinutesAfterMidnight + . 1 ) |
3 | wait( 1 ) |
4 | end |
What this does is sets the time of day to the time of day before plus 10 seconds, every second.
if you really want to use TimeOfDay so try this
1 | while true do |
2 | wait( 1 ) |
3 |
4 | local increase = 10 |
5 | local first = string.sub(game.Lighting.TimeOfDay, 1 , 6 ) |
6 | local num = string.sub(game.Lighting.TimeOfDay, 7 , 8 ) |
7 | local new = tostring (num+increase) |
8 | game.Lighting.TimeOfDay = first..new |
9 | end |
I extract to 2 strings and increase the latter by 10 then reassemble them again.