0

# How do I make a ColorCorrection's Tintcolor tween during a certain time of day?

Edited 7 days ago

Hey there! I have a bit of a wonky script that is supposed to make the color correction to purple during the nighttime, and regular during daytime. It works for nighttime perfectly, but does not wait until daytime to do the second tween of changing from purple, back to default. Is there anything I should change to achieve this affect?

local CC= game.Lighting.ColorCorrection
local TweenService = game:GetService("TweenService")
while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() > 16 * 60 then --Checks Nighttime
local TweenAnimation = TweenInfo.new(5, Enum.EasingStyle.Linear)
wait(5)
print("Turn purple")
local tween = TweenService:Create(CC, TweenAnimation, {TintColor = Color3.fromRGB(170, 0, 255)})--Purple nighttime tint
tween:Play()--Tween plays
wait (1)
if game.Lighting:GetMinutesAfterMidnight() > 7 * 60 then--Problem Area
print("Turn not purple")
local tween2 = TweenService:Create(CC,TweenAnimation,{TintColor = Color3.fromRGB(255, 255, 255)})--Default morning lighting
wait (5)
tween2:Play()
print("Tween successfully played")
end
end
end


Edit : Accidentally posted before I could add more details. I labeled the problem area in the script in my notes. Whatever it is that I did, it causes the tweens to loop until around 05:00:00 ingame time whereas I want the second tween to begin at that time to restart the daytime cycle.

0

I moved the problem if statement outside of the other if statement, and changed it to an elseif. I am unable to check if this works because I'm on mobile, so I hope it works, because I couldn't find anything else wrong with the code.

local CC= game.Lighting.ColorCorrection
local TweenService = game:GetService("TweenService")
local TweenAnimation = TweenInfo.new(5, Enum.EasingStyle.Linear)
while true do
wait(0.1)
if game.Lighting:GetMinutesAfterMidnight() > 16 * 60 then --Checks Nighttime
wait(5)
print("Turn purple")
local tween = TweenService:Create(CC, TweenAnimation, {TintColor = Color3.fromRGB(170, 0, 255)})--Purple nighttime tint
tween:Play()--Tween plays
wait (1)
elseif game.Lighting:GetMinutesAfterMidnight() > 7 * 60 then --Checks Daytime
print("Turn not purple")
local tween2 = TweenService:Create(CC,TweenAnimation,{TintColor = Color3.fromRGB(255, 255, 255)})--Default morning lighting
wait (5)
tween2:Play()
print("Tween successfully played")
end
end



I think the problem with your code was that it was checking if the time was day inside the if statement checking if it was night. This caused the script to only check if the time was after the morning, when it was night.

0
This works perfectly! Seems about right for me to mess up something so miniscule. Thanks for teaching me something new! Take care! FrigidusIncendium 16 — 7d