How do I disable clouds at night?

  1. What do you want to achieve? I want to disable clouds at night, since when it’s night, the clouds stay white, which looks pretty ugly.
Images

Day:
image

Night:

  1. What is the issue? I am not experienced in coding and therefore do not know how to make or edit a script to make this feature.

  2. What solutions have you tried so far? I tried editing this script but I could not get it to work.

That script
local timetoturnon = 7 * 60 --multiply the hour to minute
local timetoturnon = 23*60 --same

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
     if game.Lighting:GetMinutesAfterMidnight() > timetoturnoff and game.Lighting:GetMinutesAfterMidnight() < timetoturnon then
         --so If time is currently after 7 am and before 23 o'clock the light will be off
         for _, v in pairs(script.Parent.Parkinglotlightparts:GetChildren()) do
              v.LightPart.SpotLight.Enabled = false
         end
     else
             for _, v in pairs(script.Parent.Parkinglotlightparts:GetChildren()) do
                    v.LightPart.SpotLight.Enabled = false
             end
     end
end)

Thanks in advance!

1 Like

lets assume you know the basics; if you’re using the terrain clouds it’d be better just to tween down their density and cover after it hits a certain time.

that’s the easiest way I can think of.

The variables are the same. Your scrip states it needs timetoturnoff.

Simple. Delete the clouds once the sky is dark enough

You should not delete and reclone it, That’s bad for perfomance, And that script of mine was old

local timetoturnon = 7 * 60 --multiply the hour to minute
timetoturnon = 23*60 --same

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
     if game.Lighting:GetMinutesAfterMidnight() > timetoturnoff and    game.Lighting:GetMinutesAfterMidnight() < timetoturnon then
         --so If time is currently after 7 am and before 23 o'clock the light will be off
         game.workspace.Terrain.Clouds.Enabled = false
     else
              game.workspace.Terrain.Clouds.Enabled = true
     end
end)

Should be in a local script for better performance,It shouldn’t be a problem if an exploiter disables it

here is a demo project
SkyTransition.rbxl (35.3 KB)

and this is the code in the project

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local clouds = workspace:WaitForChild("Terrain"):WaitForChild("Clouds")
local tween1 = tweenService:Create(clouds, tweenInfo, {["Cover"] = 0.0})
local tween2 = tweenService:Create(clouds, tweenInfo, {["Cover"] = 0.6})
local enabled = true

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime > 6 and game.Lighting.ClockTime < 18 then
		if enabled == true then return end
		enabled = true
		tween2:Play()
	else
		if enabled == false then return end
		enabled = false
		tween1:Play()
	end
end)

another option is to tween the clouds color to make them darker at night
image

and that will look like this

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local clouds = workspace:WaitForChild("Terrain"):WaitForChild("Clouds")
local tween1 = tweenService:Create(clouds, tweenInfo, {["Color"] = Color3.new(0.2, 0.2, 0.2)})
local tween2 = tweenService:Create(clouds, tweenInfo, {["Color"] = Color3.new(1, 1, 1)})
local enabled = true

game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if game.Lighting.ClockTime > 6 and game.Lighting.ClockTime < 18 then
		if enabled == true then return end
		enabled = true
		tween2:Play()
	else
		if enabled == false then return end
		enabled = false
		tween1:Play()
	end
end)

3 Likes