Still have questions? Join our Discord server and get real time help.
0

# I want to make a roblox day and night Cycle but is not working, i code the scrip on workspace?

while true do lightning:SetMinutesAfterMidnight(lightning:GetMinutesAfterMidnight() + 0.75) wait(1) end

0
Edited 2 years ago

## 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?

1) Yes, you do put the script into the workspace.

2) 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!
0

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.)

0
And you forgot to mention that he had written "lightning" like a flash in the sky during a storm rather than "lighting" like light. kazeks123 190 — 2y
0
I hadn't caught onto that. TheRings0fSaturn 28 — 2y
0
Good eye, though! TheRings0fSaturn 28 — 2y