Roblox lied... about everything

Hello, it appears roblox lied in their documentation of color sequences. After reviewing the documentation on color sequences, I have concocted this script:

	local colorSequence = ColorSequence.new{
		ColorSequenceKeypoint(0, Color3.fromHSV(count1,1,1)),
		ColorSequenceKeypoint(1, Color3.fromHSV(count2,1,1))
	}

	script.Parent.Color = colorSequence

it appear roblox lied in their documentation though, because I am getting the fatal error of

Workspace.Pets.Wolf.Body.Aura_Attachment3.backAura.Script:66: attempt to call a table value

Roblox documentation states

1 Like

You cannot directly assign a color sequence to a color. What would you even expect that to look like?

I recommend you use their example function evalColorSequence: ColorSequence | Documentation - Roblox Creator Hub

1 Like

I expect it to look like this:

	script.Parent.Color = colorSequence

.Color is usually a Color3-type property. You cannot directly assign a ColorSequence-type object to it.

A Color is a single color. A ColorSequence is a list of possible colors.

1 Like

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)
1 Like

Your code does not match their screenshot:

ColorSequenceKeypoint(0,

as opposed to

ColorSequenceKeypoint.new(0,

3 Likes

okay I added

ColorSequenceKeypoint.new

making the code

	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)

and I got the error

Workspace.Pets.Wolf.Body.Aura_Attachment3.backAura.Script:48: attempt to compare number <= nil

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

1 Like

this is my entire code

------------------------------------------------------------
-- 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

The erroring line is this

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
1 Like

what does time mean in terms of colors? Just use my Fr*cking color

Roblox is being a total L for this. Why not just make it a basic property like

Object.ColorSequence = {
[1] = Color,
[0] = Color
}

or something

Roblox DOES make it easy. You are just using a function in it that I don’t think you even need for your use case.

1 Like

Roblox is a massive L. If I dont need the function, why would their entire documentation revolve around it? (dont answer that question)

How do I make 1 in a color sequence one color and 0 another?

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?

a fade is fine. I am trying to animate a legendary pet

I made further changes and got this sorta thing happening:


Is this close enough to what you want?

does my current one not currently do that? (also I was able to get it working but I cant tell if it does what u did in the new one or not)

Your current one just errors, last I heard.

What changes did you make to get it working? I’ll see if they are the same steps I took.

I did this

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

image
image

Similar changes.

You may want to change

if count2 > 0 then
		count2 = 1
	end

to something like

if count2 > 1 then
	count2 = 0
end