File size: 3,332 Bytes
0712d5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
-- src/ServerScriptService/DayNightManager.server.lua

local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")

-- Day/Night cycle settings
local CYCLE_SPEED = 1 -- 1 = real-time (1 min real = 1 min ingame), higher = faster
local MINUTES_PER_CYCLE = 20 -- Full day-night cycle in real minutes

-- Lighting presets
local Presets = {
	Dawn = {
		ClockTime = 6,
		Ambient = Color3.fromRGB(140, 120, 100),
		OutdoorAmbient = Color3.fromRGB(120, 100, 80),
		Brightness = 1,
		FogColor = Color3.fromRGB(200, 170, 140),
		FogEnd = 1500,
	},
	Day = {
		ClockTime = 12,
		Ambient = Color3.fromRGB(150, 150, 150),
		OutdoorAmbient = Color3.fromRGB(140, 140, 140),
		Brightness = 2,
		FogColor = Color3.fromRGB(200, 210, 220),
		FogEnd = 2000,
	},
	Dusk = {
		ClockTime = 18,
		Ambient = Color3.fromRGB(150, 100, 80),
		OutdoorAmbient = Color3.fromRGB(130, 90, 70),
		Brightness = 1,
		FogColor = Color3.fromRGB(200, 140, 100),
		FogEnd = 1200,
	},
	Night = {
		ClockTime = 0,
		Ambient = Color3.fromRGB(50, 50, 70),
		OutdoorAmbient = Color3.fromRGB(30, 30, 50),
		Brightness = 0,
		FogColor = Color3.fromRGB(40, 40, 60),
		FogEnd = 800,
	},
}

-- Initialize lighting
Lighting.ClockTime = 6
Lighting.GeographicLatitude = 40
Lighting.GlobalShadows = true

-- Add atmosphere
local atmosphere = Instance.new("Atmosphere")
atmosphere.Density = 0.3
atmosphere.Offset = 0.25
atmosphere.Color = Color3.fromRGB(199, 199, 199)
atmosphere.Decay = Color3.fromRGB(92, 60, 13)
atmosphere.Glare = 0
atmosphere.Haze = 1
atmosphere.Parent = Lighting

-- Add sky
local sky = Instance.new("Sky")
sky.SunAngularSize = 11
sky.MoonAngularSize = 9
sky.Parent = Lighting

-- Add bloom effect
local bloom = Instance.new("BloomEffect")
bloom.Intensity = 0.2
bloom.Size = 24
bloom.Threshold = 0.9
bloom.Parent = Lighting

-- Add color correction
local colorCorrection = Instance.new("ColorCorrectionEffect")
colorCorrection.Brightness = 0
colorCorrection.Contrast = 0.1
colorCorrection.Saturation = 0.15
colorCorrection.TintColor = Color3.new(1, 1, 1)
colorCorrection.Parent = Lighting

-- Add sun rays
local sunRays = Instance.new("SunRaysEffect")
sunRays.Intensity = 0.05
sunRays.Spread = 0.5
sunRays.Parent = Lighting

-- Smooth day/night cycle
local cycleStep = (24 / (MINUTES_PER_CYCLE * 60)) * CYCLE_SPEED

task.spawn(function()
	while true do
		Lighting.ClockTime = (Lighting.ClockTime + cycleStep) % 24

		-- Adjust lighting properties based on time of day
		local time = Lighting.ClockTime

		if time >= 5 and time < 7 then
			-- Dawn transition
			local t = (time - 5) / 2
			colorCorrection.TintColor = Color3.new(1, 0.9 + t * 0.1, 0.85 + t * 0.15)
			sunRays.Intensity = 0.02 + t * 0.06
		elseif time >= 7 and time < 17 then
			-- Full day
			colorCorrection.TintColor = Color3.new(1, 1, 1)
			sunRays.Intensity = 0.05
		elseif time >= 17 and time < 19 then
			-- Dusk transition
			local t = (time - 17) / 2
			colorCorrection.TintColor = Color3.new(1, 0.95 - t * 0.1, 0.9 - t * 0.2)
			sunRays.Intensity = 0.08 - t * 0.06
		else
			-- Night
			colorCorrection.TintColor = Color3.new(0.8, 0.8, 0.95)
			sunRays.Intensity = 0
		end

		task.wait(1)
	end
end)

print("Day/Night cycle started")