--!strict -- PORTFOLIO SAMPLE / ROBLOX STUDIO VALIDATION REQUIRED -- Put this Script in ServerScriptService in a separate test experience. -- A full day passes every CYCLE_SECONDS seconds. local Lighting = game:GetService("Lighting") local RunService = game:GetService("RunService") local CYCLE_SECONDS = 8 * 60 -- 8 minutes for a full 24-hour in-game day local START_HOUR = 12 local DAY_BRIGHTNESS = 2.5 local NIGHT_BRIGHTNESS = 0.4 local DAY_AMBIENT = Color3.fromRGB(145, 155, 170) local NIGHT_AMBIENT = Color3.fromRGB(53, 65, 100) local currentHour = START_HOUR Lighting.ClockTime = START_HOUR RunService.Heartbeat:Connect(function(deltaTime: number) currentHour = (currentHour + (deltaTime / CYCLE_SECONDS) * 24) % 24 Lighting.ClockTime = currentHour -- 0 at midnight, 1 at noon, smooth across sunrise/sunset. local sunFactor = math.clamp((math.cos((currentHour - 12) * math.pi / 12) + 0.2) / 1.2, 0, 1) Lighting.Brightness = NIGHT_BRIGHTNESS + (DAY_BRIGHTNESS - NIGHT_BRIGHTNESS) * sunFactor Lighting.OutdoorAmbient = NIGHT_AMBIENT:Lerp(DAY_AMBIENT, sunFactor) end)