-- Declare variables for the length of the day and night cycles
local dayLength = 150
local nightLength = 500
-- Create variables to track the current fog density and fade rate
local fogDensity = 0
local fogFadeRate = 0
-- Create a boolean variable to track whether it is currently day or night
local isDay = true
-- Create a timer to switch between day and night
local switchTimer = game:GetService("RunService").Stepped:Connect(function()
-- Decrement the length of the current cycle
if isDay then
dayLength = dayLength - 1
else
nightLength = nightLength - 1
end
-- If the current cycle has ended, switch to the other cycle and reset the timer
if dayLength <= 0 then
isDay = false
dayLength = 150
elseif nightLength <= 0 then
isDay = true
nightLength = 500
end
-- Update the skybox and lighting based on the current cycle
if isDay then
game.Lighting.TimeOfDay = 0
game.Lighting.FogColor = Color3.new(0.8, 0.8, 0.8)
game.Lighting.OutdoorAmbient = Color3.new(0.6, 0.6, 0.6)
-- Slowly decrease the fog density
fogDensity = math.max(fogDensity - 0.01, 0)
fogFadeRate = -0.01
else
game.Lighting.TimeOfDay = 0.5
game.Lighting.FogColor = Color3.new(0.2, 0.2, 0.2)
game.Lighting.OutdoorAmbient = Color3.new(0.1, 0.1, 0.1)
-- Slowly increase the fog density
fogDensity = math.min(fogDensity + 0.01, 1)
fogFadeRate = 0.01
end
-- Update the fog density
game.Lighting.FogEnd = 100 + fogDensity * 200
end)
A number does not need to be a string as it is an integer. I have figured out that maybe this can help:
if dayLength <= 0 or nightLength <= 0 then
if dayLength <= 0 then
isDay = false
dayLength = 150
elseif nightLength <= 0 then
isDay = true
nightLength = 500
end
end