Hello, it appears roblox lied in their documentation of color sequences. After reviewing the documentation on color sequences, I have concocted this script:
I tried doing this script but it still isnt working:
---------------
--// Functions
---------------
local function evalColorSequence(sequence: ColorSequence, time: number)
-- If time is 0 or 1, return the first or last value respectively
if time == 0 then
return sequence.Keypoints[1].Value
elseif time == 1 then
return sequence.Keypoints[#sequence.Keypoints].Value
end
-- Otherwise, step through each sequential pair of keypoints
for i = 1, #sequence.Keypoints - 1 do
local thisKeypoint = sequence.Keypoints[i]
local nextKeypoint = sequence.Keypoints[i + 1]
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
-- Calculate how far alpha lies between the points
local alpha = (time - thisKeypoint.Time) / (nextKeypoint.Time - thisKeypoint.Time)
-- Evaluate the real value between the points using alpha
return Color3.new(
(nextKeypoint.Value.R - thisKeypoint.Value.R) * alpha + thisKeypoint.Value.R,
(nextKeypoint.Value.G - thisKeypoint.Value.G) * alpha + thisKeypoint.Value.G,
(nextKeypoint.Value.B - thisKeypoint.Value.B) * alpha + thisKeypoint.Value.B
)
end
end
end
---------------
--// Code
---------------
local colorSequence = ColorSequence.new{
ColorSequenceKeypoint(0, Color3.fromHSV(count1,1,1)),
ColorSequenceKeypoint(1, Color3.fromHSV(count2,1,1))
}
script.Parent.Color = evalColorSequence(colorSequence)
That’s an entirely unrelated error to do with something further down in your code. It appears now because the script is no longer stopping at the error to do with color sequence
------------------------------------------------------------
-- This script handles color animation functionality on the server side.
-- Written by AverageRobloxDev2. All rights reserved.
------------------------------------------------------------
---------------
--// Preset Variables
---------------
local Players = game.Players
local Lighting = game.Lighting
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvents = ReplicatedStorage.RemoteEvents
local STC = RemoteEvents.STC --// [STC] Send
local CTS = RemoteEvents.CTS --// [CTS] Receive
local RepAssets = ReplicatedStorage.RepAssets
local TweenService = game:GetService("TweenService")
local DataStoreService = game:GetService("DataStoreService")
local ServerStorage = game.ServerStorage
local StorageAssets = ServerStorage.StorageAssets
---------------
--// Variables
---------------
local speed = 1 --Change to speed you want
local count1 = 0
local count2 = 0
---------------
--// Functions
---------------
local function evalColorSequence(sequence: ColorSequence, time: number)
-- If time is 0 or 1, return the first or last value respectively
if time == 0 then
return sequence.Keypoints[1].Value
elseif time == 1 then
return sequence.Keypoints[#sequence.Keypoints].Value
end
-- Otherwise, step through each sequential pair of keypoints
for i = 1, #sequence.Keypoints - 1 do
local thisKeypoint = sequence.Keypoints[i]
local nextKeypoint = sequence.Keypoints[i + 1]
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
-- Calculate how far alpha lies between the points
local alpha = (time - thisKeypoint.Time) / (nextKeypoint.Time - thisKeypoint.Time)
-- Evaluate the real value between the points using alpha
return Color3.new(
(nextKeypoint.Value.R - thisKeypoint.Value.R) * alpha + thisKeypoint.Value.R,
(nextKeypoint.Value.G - thisKeypoint.Value.G) * alpha + thisKeypoint.Value.G,
(nextKeypoint.Value.B - thisKeypoint.Value.B) * alpha + thisKeypoint.Value.B
)
end
end
end
---------------
--// Code
---------------
while true do
task.wait()
count1 = count1 * 0.001*speed
count2 = count2 * 0.001/speed
if count1 > 1 then
count1 = 0
end
if count2 > 0 then
count2 = 1
end
local colorSequence = ColorSequence.new{
ColorSequenceKeypoint.new(0, Color3.fromHSV(count1,1,1)),
ColorSequenceKeypoint.new(1, Color3.fromHSV(count2,1,1))
}
script.Parent.Color = evalColorSequence(colorSequence)
end
I am trying to animate the color of a gradient to be rainbow
0 on the gradient is the opposite side of the rainbow as 1
if time >= thisKeypoint.Time and time < nextKeypoint.Time then
It errors because the function it is contained in requires 2 parameters, colorSequence and time
However, when you are calling the function, you only provided colorSequence
script.Parent.Color = evalColorSequence(colorSequence) -- Problematic function call
Do you want it to be a gradient or a fade?
By modifying the code you provided, I was able to get a fade to work. I don’t think that that is what you wanted though?
while true do
task.wait()
count1 = count1 + 0.001*speed
count2 = count2 + 0.001/speed
if count1 > 1 then
count1 = 0
end
if count2 > 0 then
count2 = 1
end
local Color1 = ColorSequenceKeypoint.new(0, Color3.fromHSV(count1,1,1))
local Color2 = ColorSequenceKeypoint.new(1, Color3.fromHSV(count2,1,1))
script.Parent.Color = ColorSequence.new({Color1, Color2})
end
however I am noticing that the top is stuck at red