How To make A Day And Night Cycle in Roblox Studio

Опубликовано: 22 Март 2026
на канале: MoreKeyHitt
91,393
1.7k

Hope You Like It :D

Script -
-- Get the Lighting service
local lighting = game:GetService("Lighting")


local dayLength = 15 -- Change this to the length of your day in seconds
local nightLength = 15 -- Change this to the length of your night in seconds


while true do
-- Day time: 6 AM to 6 PM
for i = 6 * 60, 18 * 60 do
lighting:SetMinutesAfterMidnight(i)
wait(dayLength / (12 * 60))
end

-- Night time: 6 PM to 6 AM
for i = 18 * 60, 24 * 60 do
lighting:SetMinutesAfterMidnight(i)
wait(nightLength / (12 * 60))
end
for i = 0, 6 * 60 do
lighting:SetMinutesAfterMidnight(i)
wait(nightLength / (12 * 60))
end
end