Hello! I am getting stumped on getting this script to smoothly transition from one cycle to another. As you can see, I am doing a weather cycle, and I have this script for the cloud colors:
if WeatherCycle == 'Clear' then -- Sets weather values
Rain:Disable()
local cloudColors = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.new(0.0196078, 0.0196078, 0.0392157)), -- 00:00 (12 AM) Midnight
ColorSequenceKeypoint.new(0.15, Color3.new(0.0705882, 0.0705882, 0.0784314)),
ColorSequenceKeypoint.new(0.22, Color3.new(0.117647, 0.0941176, 0.0941176)),
ColorSequenceKeypoint.new(0.25, Color3.new(1, 0.360784, 0.360784)), -- 06:00 (6 AM) Morning
ColorSequenceKeypoint.new(0.5, Color3.new(0.784314, 0.784314, 0.784314)), -- 12:00 (12 PM) Noon
ColorSequenceKeypoint.new(0.75, Color3.new(1, 0.360784, 0.360784)), -- 18:00 (6 PM) Morning
ColorSequenceKeypoint.new(0.78, Color3.new(0.117647, 0.0941176, 0.0941176)),
ColorSequenceKeypoint.new(0.85, Color3.new(0.0705882, 0.0705882, 0.0784314)),
ColorSequenceKeypoint.new(1, Color3.new(0.0196078, 0.0196078, 0.0392157)) -- 00:00 (12 AM) Midnight
}
local function Update()
clouds.Color = evalCS(cloudColors, lighting.ClockTime / 24)
end
lighting:GetPropertyChangedSignal("ClockTime"):Connect(Update)
Update()
elseif WeatherCycle == 'Rain' then
local cloudColors = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.new(1, 0, 0.0156863)),
ColorSequenceKeypoint.new(0.15, Color3.new(1, 0, 0)),
ColorSequenceKeypoint.new(0.22, Color3.new(0, 0.384314, 1)),
ColorSequenceKeypoint.new(0.25, Color3.new(1, 0, 0.0156863)),
ColorSequenceKeypoint.new(0.5, Color3.new(0.784314, 0, 0.168627)),
ColorSequenceKeypoint.new(0.75, Color3.new(1, 0.117647, 0.117647)),
ColorSequenceKeypoint.new(0.78, Color3.new(0.686275, 0, 0.737255)),
ColorSequenceKeypoint.new(0.85, Color3.new(0.482353, 0.301961, 0.933333)),
ColorSequenceKeypoint.new(1, Color3.new(0.694118, 0.6, 0.0784314))
}
local function Update()
clouds.Color = evalCS(cloudColors, lighting.ClockTime / 24)
end
lighting:GetPropertyChangedSignal("ClockTime"):Connect(Update)
Update()
This works with the function:
local lighting = game:GetService("Lighting")
local clouds = workspace.Terrain.Clouds
-- ColorSequence stuff stolen directly from https://developer.roblox.com/en-us/api-reference/datatype/ColorSequence
-- Bro shoutout to that dude he saved my butt! I did make some edits :) ~ King Noob
-- first and last colors should probably match!
function evalCS(cs, time)
-- If we are at 0 or 1, return the first or last value respectively
if time == 0 then return cs.Keypoints[1].Value end
if time == 1 then return cs.Keypoints[#cs.Keypoints].Value end
-- Step through each sequential pair of keypoints and see if alpha
-- lies between the points' time values.
for i = 1, #cs.Keypoints - 1 do
local this = cs.Keypoints[i]
local next = cs.Keypoints[i + 1]
if time >= this.Time and time < next.Time then
-- Calculate how far alpha lies between the points
local alpha = (time - this.Time) / (next.Time - this.Time)
-- Evaluate the real value between the points using alpha
return Color3.new(
(next.Value.R - this.Value.R) * alpha + this.Value.R,
(next.Value.G - this.Value.G) * alpha + this.Value.G,
(next.Value.B - this.Value.B) * alpha + this.Value.B
)
end
end
end
I was wondering how I can get these color sequences to smoothly transition from one to another based on if it’s raining or not. Got any tips?