Here my new code, I used spawn(function()
:
--variable--
local Clouds = game.Workspace.Terrain:WaitForChild("Clouds")
local Spring = false
local Summer = false
local Autumn = false
local Winter = true
local Day = 1
local Month = 1
local Year = 2022
local LeapYear = false
local Time
--variable--
--SetTime--
spawn(function()
while wait() do
Time = game.Lighting.TimeOfDay
end
end)
--SetTime--
--SetTheDate--
spawn(function()
while wait() do
if Time == "00:00:00" then
Day = Day + 1
if Month == 1 or 3 or 5 or 7 or 9 or 11 then
if Day == 32 then
Month = Month + 1
Day = 1
end
elseif Month == 4 or 6 or 8 or 10 or 12 then
if Day == 31 then
Month = Month + 1
Day = 1
end
elseif Month == 2 then
if LeapYear == true then
if Day == 30 then
Month = Month + 1
Day = 1
end
else
if Day == 29 then
Month = Month + 1
Day = 1
end
end
elseif Month == 13 then
Year = Year + 1
Month = 1
end
end
end
end)
--SetTheDate--
--CheckIfIsALeapYear--
spawn(function()
while wait() do
if Year.Value % 4 == 0 then
LeapYear = true
else
LeapYear = false
end
end
end)
--CheckIfIsALeapYear--
--Season--
spawn(function()
while wait() do
if Day == 21 and Month == 3 then
Winter = false
Spring = true
elseif Day == 21 and Month == 6 then
Spring = false
Summer = true
elseif Day == 21 and Month == 9 then
Summer = false
Autumn = true
elseif Day == 21 then
Autumn = false
Winter = true
end
end
end)
--Season--
--Weather--
spawn(function()
while wait() do
if Time == "12:00:00" then
if Summer then
if math.random(0,5) < 5 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(0,50)/100
Clouds.Color = Color3.new(1, 1, 1)
game.Lighting.Brightness = 6
else
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(50,75)
Clouds.Color = Color3.new(1, 1, 1)
game.Lighting.Brightness = 6
end
elseif Autumn then
if math.random(0,2) == 1 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(50,100)/100
Clouds.Color = Color3.new(0.713725, 0.713725, 0.713725)
game.Lighting.Brightness = 4
if math.random(0,10) == 1 and Clouds.Cover > 0.9 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
Clouds.Color = Color3.new(0.458824, 0.458824, 0.458824)
game.Lighting.Brightness = 2
end
elseif math.random(0,5) == 1 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(0,50)/100
Clouds.Color = Color3.new(0.882353, 0.882353, 0.882353)
game.Lighting.Brightness = 4
else
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(0,25)/100
Clouds.Color = Color3.new(1, 1, 1)
game.Lighting.Brightness = 6
end
elseif Winter then
if math.random(0,3) < 3 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(90,100)/100
Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
game.Lighting.Brightness = 2
if math.random(0,3) < 3 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
print("rain")
end
else
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(70,90)/100
Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
game.Lighting.Brightness = 4
end
elseif Spring then
if math.random(0,5) < 3 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(30,70)/100
Clouds.Color = Color3.new(1, 1, 1)
game.Lighting.Brightness = 6
elseif math.random(0,5) < 5 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(70,90)/100
Clouds.Color = Color3.new(0.619608, 0.619608, 0.619608)
game.Lighting.Brightness = 4
else
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = true
Clouds.Cover = math.random(90,100)/100
Clouds.Color = Color3.new(0.45098, 0.45098, 0.45098)
game.Lighting.Brightness = 2
if math.random(0,4) == 1 then
game.StarterPlayer.StarterPlayerScripts.RainScript.Disabled = false
end
end
end
end
end
end)
--Weather--