I’m playing around with UI Color gradients a bit, but I’ve ran into an issue:
Why does this code not work?
for i = 1, 10 do
gradtable = {}
for x = 1, 10 do
local colorkey = ColorSequenceKeypoint.new(x / 10, Color3.new(0,0,1))
gradtable["pixel" .. x] = colorkey
end
local colors = ColorSequence.new(gradtable)
colors.Name = "colorsequence" .. i
end
The error I’m getting is “ColorSequence: requires at least 2 keypoints”
I’ve tried printing the table, and it returns the color sequence values
I don’t need anything releated to putting it onto a frame or screen, just the ColorSequence part
your issue is your giving ColorSequence a Dict (string: ColorSequenceKeypoint), ColorSequence only accepts an array of ColorSequenceKeypoint
replace gradtable["pixel" .. x] = colorkey with table.insert(gradtable, colorkey)
This still wont work as you need the timestamp of the ColorSequenceKeypoint to start at 0 and end a 1 so I believe it should be as follows?
for i = 1, 10 do
local gradtable = {}
for x = 0, 10 do -- Start from 0
local time = x / 10
local colorkey = ColorSequenceKeypoint.new(time, Color3.new(0, 0, 1))
table.insert(gradtable, colorkey)
end
print(gradtable)
local colors = ColorSequence.new(gradtable)
-- You can't set .Name on ColorSequence (it's not an Instance)
-- So this line is invalid: colors.Name = "colorsequence" .. i
end