Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a night and day cycle need help!?

Asked by 5 years ago

So I'm trying to make a night and day cycle but I can't seem to make it the time I want I'm trying to make it 20 minutes as a day if that's to hard I might do 18 but here's the script can anyone help me figure out what numbers to put to make it 20 minutes as a day?. Thank you!

while wait(0.3)do game.Lighting:SetMinutesAfterMidnight(game.Lighting:GetMinutesAfterMidnight()+0.3) end

1
Next time, use code blocks to present code. DemonHunterz6 35 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This was taken from the "DayNight" script of the "Realism Mod (V2.08)" plugin.

01local lighting = game:GetService("Lighting")
02local tweenService = game:GetService("TweenService")
03 
04local dayLength = 1200 -- How many real-time seconds an in-game day will last. In your case, 20 minutes (1200 seconds).
05local nightLength = 150 -- How many real-time seconds an in-game night will last. Edit this however you like.
06 
07function tween (l, p)
08    tweenService:Create(lighting, TweenInfo.new(l, Enum.EasingStyle.Linear, Enum.EasingDirection.In), p):Play()
09end
10 
11lighting.ClockTime = 6
12 
13while dayLength ~= nil do
14 
15    tween(dayLength, {ClockTime = 18})
View all 25 lines...

I edited it a bit so that a day lasted 20 minutes, so I guess here you go. It's really simple math, since 60 (seconds in a minute) multiplied by 20 (minutes) is 1200.

0
Thank you so much! :) matty123465 11 — 5y
0
No problem. DemonHunterz6 35 — 5y
Ad

Answer this question