Need help with this simple weather system

Greetings everyone, I am trying to make a simple weather system, but for some reason in the second if statement, one of the properties that i want to change isn’t changing.

heres my code

local lighting = game.Lighting
local atmosphere = lighting.Atmosphere
local clouds = game.Workspace.Terrain:WaitForChild("Clouds")
local event = game.ReplicatedStorage:WaitForChild("dnwCycleEvent")

event.OnClientEvent:Connect(function()
	while true do
		wait(1)
		lighting.ClockTime = lighting.ClockTime+1
		if lighting.ClockTime > 17 then
			clouds.Cover = 0.7
			night = true
		elseif lighting.ClockTime > 21 then
			clouds.Cover = 0.9
			clouds.Color = Color3.fromRGB(0,0,0)
			atmosphere.Haze = 0
			atmosphere.Glare = 10
			atmosphere.Color = Color3.fromRGB(81,81,81)
			atmosphere.Decay = Color3.fromRGB(58,58,58)
		elseif lighting.ClockTime == 0 then
			break
		end
	end
end)

The property that isn’t changing is the

clouds.Cover = 0.9
clouds.Color = Color3.fromRGB(0,0,0)

but beyond that, everything else is working, and i have no clue why.

Thats intresting but could be due to the lighting is clocktime as the lighting is a factor that could hinder its visibility of the color change and maybe the atmosphere as well

1 Like

Just edited the part that didnt work, it was hiding the main thing, which was the clouds.Cover property. For some reason it works for the first change (that being when the clock time is greater than 17), but when the clocktime is greater than 21, nothing from the “Clouds” object changes. Everything else, including the atmosphere works fine.

Can you provide a picture of the descendants tree of the terrain?

Ok, so basically, you are checking if its greater than 17, and then if that statement is not true, it checks if its greater then 21. to be 21 (or more, it will always be greater then 17 and trigger the first if statement)

1 Like
		if lighting.ClockTime > 17 and lighting.ClockTime <= 21 then
			clouds.Cover = 0.7
			night = true
		elseif lighting.ClockTime > 21 then
			clouds.Cover = 0.9
			clouds.Color = Color3.fromRGB(0,0,0)
			atmosphere.Haze = 0
			atmosphere.Glare = 10
			atmosphere.Color = Color3.fromRGB(81,81,81)
			atmosphere.Decay = Color3.fromRGB(58,58,58)
		elseif lighting.ClockTime == 0 then
			break
		end
1 Like

I see, it works now. Thank you