i would like to make a day / night cycle script
yeah i can take one for free, sure. but i would like to make my own, what i should do first ?
You should figure out how long you want your day/night cycle to be, first.
Next, you need to understand how to use "setMinutesAfterMidnight" and also how to use variables and loops.
Third, you need to declare a variable in the fashion
y = 0
From there, we can create a loop that runs itself as quickly as possible (add a number into the () of the wait() in order to slow this down)
while wait() do end
And then we need to tell the game that it needs to set the time. Because setMinutesAfterMidnight is a function that is used on the Lighting part of the game, we need to tell the script to run it on Lighting.
while wait() do game.Lighting:setMinutesAfterMidnight() end
However, as it is, that does nothing. This is where our variable 'y' comes into play. If we want to change the time, all we have to do is force y to be the new, ah, parameter of the setMinutesAfterMidnight function.
while wait() do game.Lighting:setMinutesAfterMidnight(y) end
Now all we have to do is make sure that y changes, and we do that by saying
while wait() do game.Lighting:setMinutesAfterMidnight(y) y = y + 1 end
So now the entire script will look like:
y= 0 while wait() do game.Lighting:setMinutesAfterMidnight(y) y = y + 1 end
What this does is 1) Sets the variable 'y' to equal 0 at the beginning of the script. 2) Forces the script into a never-ending cycle with the 'while wait() do' loop 3) Tells the script to set the time to 'y' minutes after midnight 4) Adds 1 to 'y' - This means that every time the loop runs, one minute will be added to the time after midnight.
Again: if you want the script to have a longer day cycle, simply do something like:
while wait(1) do game.Lighting:setMinutesAfterMidnight(y) y = y + 1 end
What that will do is increase the interval for each minute to pass to one second. One second of IRL time would therefore be equivalent to 1 minute of day time.
I hope this helps you ^_^
l = game:service("Lighting") r = game:service("RunService") while true do --Time and day l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+1) wait(.7) end