SetTween not playing despite it being made to play between 16.5/7.5 and 18.1/6 on ClockTime

Hi there.

I wanted to achieve a basic ClockTime-based Atmosphere system that changes the Ambient property based on ClockTime.
I wanted to use the SetTween as a way to indicate a ClockTime between 16.5/7.5 and 18.1/6, but only SunTween and MoonTween play for some reason.

Code:

local Options = TweenInfo.new(
	1,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out
)

local TweenService = game:GetService("TweenService")
local Lighting = game:GetService("Lighting")

local function ChangeAtmosphere(clockTime: number)
	local SunTween = TweenService:Create(Lighting, Options, {Ambient = Color3.fromRGB(300, 300, 300)})
	local SetTween = TweenService:Create(Lighting, Options, {Ambient = Color3.fromRGB(300, 200, 0)})
	local MoonTween = TweenService:Create(Lighting, Options, {Ambient = Color3.fromRGB(127, 127, 127)})

	if clockTime >= 18.1 or clockTime <= 6 then
		MoonTween:Play()
	elseif clockTime <= 16.5 or clockTime >= 7.5 then
		SunTween:Play()
	else
		SetTween:Play()
	end
end

task.spawn(function()
	while true do
		task.wait(0.1)
		ChangeAtmosphere(Lighting.ClockTime)
	end
end)

I tried adjusting the min and max, switching them around and even used an “else” but, nothing happened.

Please let me know if there’s a proper solution to this.

Thank you :+1:

1 Like