Allow editing of SequenceKeypoints. (ColorSequence, NumberSequence)

I am trying to create an easy way of changing the color a particle emitter gives off, at a very specific point in its emission; I already know which point in the sequence this is, and I wish to change its “color” property.

I would like to use the code;
RedSequence.Keypoints[2].Value = color3.new(0,0,.9)
To change the color value from .color3.new(9,0,0) (Red to blue, essentially.)
However; “Value cannot be assigned to”.
No biggie, I’ll just change the whole Keyframe;
RedSequence.Keypoints[2] = ColorSequenceKeypoint.new(.2, color3.new(0,0,.9))
No errors this time, must’ve worked! But my emitter keypoint hasn’t changed color, perhaps its being overriden by the pre-existing Keypoint, I’ll just make it nil, then try again.
Doesn’t work.

Once a Sequence has been made, it appears there is no way to edit it. This is rather annoying, as I have the one sequence I’m very comfortable with, and only have 1 part of this sequence I wish to change. The alternative to this is just holding a large selection of Sequences, or creating them all uniquely.

The following code will throw no errors, but the emitter will remain unchanged;

local CSK = ColorSequenceKeypoint.new
local c3 = Color3.new
local End = CSK(1, c3(0,0,0))
local Start = CSK(0, c3(1,.55,.55))
local MidRed = CSK(0.08, c3(.9,0,0))
local MidBlue = CSK(0.08, c3(0,0,.9))
local RedSequence = ColorSequence.new({Start, MidRed, End})

print(RedSequence)
RedSequence.Keypoints[2] = nil
RedSequence.Keypoints[2] = MidBlue
--RedSequence.Keypoints[2].Value = c3(0,0,.9) --< This will throw a "Cannot assign"
print(RedSequence)
2 Likes

The lack of an error seems to be because you are editing a Lua table instead of the table being locked (may be a bug).
Implementing this change may have some unwanted consequences because of the benefit of immutable (unchangable) properties: you don’t need to listen for changes. If this was to be implemented, developers that use SequenceKeypoints for other subsystems would also need to implement checking for changes, and Roblox would also need to expose the ability to receive events for changes. While it would be useful to have this, the changes that would lead it to be mutable (changable) may be too much.

2 Likes