When I Try To Use ColorSequence It Errors When In The API It Says To Do It The Way I Did?

When I Try To Use ColorSequence It Errors When In The API It Says To Do It The Way I Did???

https://developer.roblox.com/en-us/api-reference/datatype/ColorSequence

ColorSequence.new({
      ColorSequenceKeypoint.new(0, Color3.fromRGB(0.4, 0.160784, 1)),
      ColorSequenceKeypoint.new(0, Color3.fromRGB(0.556863, 0.239216, 1)),
      ColorSequenceKeypoint.new(1, Color3.fromRGB(0.823529, 0.290196, 1))
})

When I run the code above it errors, and the error is bad argument #3 (NumberSequence expected, got number)

If you know how to fix this please reply.

1 Like
local seq = ColorSequence.new({
      ColorSequenceKeypoint.new(0, Color3.fromRGB(0.4, 0.160784, 1)),
      ColorSequenceKeypoint.new(0, Color3.fromRGB(0.556863, 0.239216, 1)),
      ColorSequenceKeypoint.new(1, Color3.fromRGB(0.823529, 0.290196, 1))
})
print(seq)

This code doesn’t give me an error?

Output:
0 0.00156863 0.000630526 0.00392157 0 0 0.00218378 0.000938102 0.00392157 0 1 0.00322953 0.00113802 0.00392157 0

This code isn’t the problem. You aren’t interpreting the error correctly; whatever you’re using this code for, it is expecting a NumberSequence and you’re passing a ColorSequence.

1 Like

It doesn’t give me an error when I try to print it but when I try to set it to the color property for a UIGradient it gives an error saying bad argument #3 (NumberSequence expected, got number)

Are you trying to change the Transparency? That needs a NumberSequence.

Show us the full code; it doesn’t seem you’re actually passing a number sequence…