Ugly I know!
Once the time of day reached 19 I skipped to 21 after a few second and then skipped to 5. Then I switched around the time of the waits so it would be a slower transition. The problem was that the time transition was super abrupt.
So I came to the forum:
Is there a way I can make the nights shorter?
local lighting = game:GetService("Lighting")
local information = {
Time = 1; -- The time between each increment
Increment = .5 -- the amount that the time of day will increment by
}
while true do -- repeat while the server is open
lighting.ClockTime = lighting.ClockTime + information.Increment -- increase the time by (in this case) 1/2 of a second
wait(information.Increment) -- wait the set time
end
Hope this helped!
EDIT: This would be a more suitable solution, actually.
Also make sure to use the RunService to keep the movement of the cycle smooth (Wait()) makes it look choppy.
You could also just adjust the value to whatever seems to fit what you need.
local lighting = game.Lighting
local MAM = 0
local Time = 1 -- set to anything
while true do
lighting:SetMinutesAfterMidnight(MAM)
MAM = MAM + Time
game:GetService("RunService").Heartbeat:Wait()
end
Yep, this is actually a good way to do it. It’s really personal preference, since if you make the time quick enough it’s not choppy. If you are looking to have it slower than most games, this is the way to go.
Both your and @Sqowly’s codes work. The problem is that it makes the day run as fast as the night time. The reason I made that code in the above post was so that it would stay at a normal pace for the day but go faster for the night-time.
But this is a bit exhausting code. Not very clear and concise.
To make the night shorter I skipped from 19 to 21 then 21 to 24 and 24 to 4. Then I went in normal increments of .5 for the rest of it.
I would also not recommend supporting that at all either.
What you could do instead is a combination of a loop and ifstatement.
Using your code from before and changing it:
local lighting = game:GetService("Lighting") -- Use getservice instead
while true do
if if lighting.TimeOfDay >= bla bla and lighting.TimeOfDay <= -- night (probs a better way but this is something that is much shorter)
lighting:SetMinutesAfterMidnight(lighting:GetMinutesAfterMidnight() + 0.45)
wait(1)
elseif lighting.TimeOfDay >= bla bla and lighting.TimeOfDay <= then -- day (probs a better way but this is something that is much shorter)
lighting:SetMinutesAfterMidnight(lighting:GetMinutesAfterMidnight() + 0.75)
wait(1)
end
-- this is only an example, you'll want to change the if statement values and change the day value so that if fits your script.
Code smells are generally often terrible practice and shouldn’t be done (as you’ve done with the huge amount of waits) unless it’s your last resort and even then, there is still various amount of ways to have a better way of scripting it.
Thank you, your code is much more effective than mine . Although at the very end of the code the output sends an error message saying “Script timeout: exhausted allowed execution time”.