Im trying to make a script that between 5am and 6pm the atmosphere density is set at 0.4 and between 6pm and 5 am the atmosphere density is at 0.8
when i change the time it doesnt change the fog
ctime = game.Lighting.ClockTime
while true do
if ctime >= 5 or ctime <= 18 then
game.Lighting.Atmosphere.Density = 0.4
print("lowfog")
elseif ctime < 5 or ctime > 18 then
game.Lighting.Atmosphere.Density = 0.8
print("highfog")
end
wait(0.01)
end
ctime = game.Lighting.ClockTime -- if set at 6 will print 6 only
which means it will remain the same even after u change it
to fix your issue u should do this
ctime = game.Lighting
while true do
if ctime.ClockTime >= 5 or ctime.ClockTime <= 18 then
game.Lighting.Atmosphere.Density = 0.4
print("lowfog")
elseif ctime.ClockTime< 5 or ctime.ClockTime > 18 then
game.Lighting.Atmosphere.Density = 0.8
print("highfog")
end
wait(0.01)
end
ctime = game.Lighting
while true do
if ctime.ClockTime >= 5 and ctime.ClockTime <= 18 then
game.Lighting.Atmosphere.Density = 0.4
print("lowfog")
else
game.Lighting.Atmosphere.Density = 0.8
print("highfog")
end
wait(0.01)
end
if you are changing the time on the client, and this runs on the server it won’t work
also don’t use a loop for this
local Lightning = game:GetService("Lightning")
function CheckClockTime()
if Lightning.ClockTime >= 5 and Lightning.ClockTime <= 18 then
Lighting.Atmosphere.Density = 0.4
print("lowfog")
else
Lighting.Atmosphere.Density = 0.8
print("highfog")
end
end
Lightning:GetPropertyChangedSignal("ClockTime"):Connect(CheckClockTime)
CheckClockTime()
local Lightning = game:GetService("Lightning")
local TweenService = game:GetService("TweenService")
local Time = 1
function TweenDensity(Value)
TweenService:Create(Lightning.Atmosphere, TweenInfo.new(Time), {
Density = Value
}):Play()
end
function CheckClockTime()
if Lightning.ClockTime >= 5 and Lightning.ClockTime <= 18 then
TweenDensity(0.4)
print("lowfog")
else
TweenDensity(0.8)
print("highfog")
end
end
Lightning:GetPropertyChangedSignal("ClockTime"):Connect(CheckClockTime)
CheckClockTime()
just set Time to how long you want the fade to take