while true do lightning:SetMinutesAfterMidnight(lightning:GetMinutesAfterMidnight() + 0.75) wait(1) end
COMMUNITY QUESTION
I want to make a roblox day and night Cycle but is not working, i code the scrip on workspace?
2 answers
Hi, TheVlogingAustin_YT. I will be helping you regarding the question, I want to make a roblox day and night Cycle but is not working, i code the scrip on workspace?
- Yes, you do put the script into the workspace.
- You haven't increased the value yet.
-- Declaration Section
local getMinutesAfterLighting = 0
-- Processing Section
while true do
getMinutesAfterLighting = getMinutesAfterLighting + 0.75
game.Lighting:SetMinutesAfterMidnight(getMinutesAfterLighting)
wait(.1)
end
Have a lovely day of coding!
A much more efficient and easier way of doing this is to write this script here:
while true do
wait(1)
game.Lighting.ClockTime = game.Ligthing.ClockTime + 0.01
end
I think this method is becoming standard. But not only that, using ClockTime instead of accessing the time of day will allow more straightforward numeric operations, and it's also much, much easier to do conditional statements using ClockTime instead of TimeOfDay, and your code is cleaner as well!
It's also recommended to place scripts into the ServerScriptService, for security reasons (clients do not have access to ServerScriptService or ServerStorage.)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
And you forgot to mention that he had written "lightning" like a flash in the sky during a storm rather than "lighting" like light.
I hadn't caught onto that.
Good eye, though!