Change Keypoint Time In A UIGradient?

Hi DevForum!

I’m trying to change the position of a keyframe in a colorsequence. How would i index the time thing that’s needed for that?

image

Thanks!

1 Like

Hello @TheRealNcMaster

If Im not mistaken you need to use colorsequensekeypoint for this

Alright, could you update the code for me? I don’t really know how to use this and i can’t find anything on the wiki. I basically want to tween the position of the keypoint on the sequence, so the “Time” value. Thanks ahead!

Do you mean you want to tween the color for the ui gradient…Im sorry I cant help you rn I have a class today…I’ll help you when Im finish my class

Button.MouseEnter:Connect(function()
   local Gradient = script.ParentUIGradient
   Gradient.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, Color3.fromRGB(0, 0, 0), ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 255, 255))}
end)

You can’t tween ColorSequence values unfortunately as they aren’t considered instances, rather a datatype. I don’t think you’re able to tween ColorSequence properties either. You’d have to use a clunky workaround using NumberValues.

Something like this should work:

local numberValue = Instance.new('NumberValue')
numberValue.Value = 1
local uiGradient = script.Parent.UIGradient
local keypoints = initGradient.Keypoints
Button.MouseEnter:Connect(function()
    tweenService:Create(numberValue, tweenInfo, {Value = 0}):Play()
end)
numberValue.Changed:Connect(function()
    uiGradient.Color = ColorSequence.new({
        keypoints[1];
        ColorSequenceKeypoint.new(numberValue.Value, keypoints[2].Value);
        keypoints[3];
    })
end)
5 Likes