I need some help with UIGradient keypoints

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 keypoints could possibly be the same, try printing gradtable and check the output

Outputs to

 17:18:20.385  0.3 0 0 1 0
  17:18:20.386  0.1 0 0 1 0 
  17:18:20.386  0.9 0 0 1 0
  17:18:20.386  0.5 0 0 1 0
  17:18:20.386  0.7 0 0 1 0
  17:18:20.386  0.2 0 0 1 0
  17:18:20.387  1 0 0 1 0
  17:18:20.387  0.6 0 0 1 0
  17:18:20.387  0.8 0 0 1 0
  17:18:20.387  0.4 0 0 1 0 

Alright, one second
Whats your expected output may i ask

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

Oooh thanks that works
ColorSequences should really have more documentation…