Hello im a Starter Developer and i would like some support on how to create a day and night cycle but its customized basically what i had in mind was:
When you join the game it will be day time but it will stay on the specific Clock Time so the Sun wont be moving like regular Day and night cycle but after a few minutes or a specific time the sun will move moderately fast [Not instant] until it reaches a specific Clock Time which is night so it looks like the celestial bodies are not moving, but there are still a day and night cycle in game.
Does that make sense? so i tried researching how to do it but couldn’t find a documentation or solution, if there was a documentation about how to make this specific day and night cycle i would like the link please Thank you very much
I Would really appreciate some support, and your support might help me become a better scripter.
You can modify Lighting.ClockTime to do this. You can also tween it for this smooth effect.
--services
local lighting = game:GetService("Lighting")
local ts = game:GetService("TweenService")
--info for tweening
local info = TweenInfo.new(
5, --time in seconds
Enum.EasingStyle.Sine, --style to animate
Enum.EasingDirection.InOut, --how the EasingStyle should be applied
0, --repeat count
false, --reverses
0 --delay time
)
--the tweens to set the time of day
local toDay = ts:Create(lighting, info, {ClockTime = 12.8})
local toNight = ts:Create(lighting, info, {ClockTime = 20.4})
--now, let's set up an iteration to continuously play the tweens
while true do
toDay:Play() --make it daytime
toDay.Completed:Wait()
task.wait(300) --wait 5 minutes
toNight:Play() --make it nighttime
toNight.Completed:Wait()
task.wait(300) --wait 5 minutes
end