I want to make a colour changing gradient UI for my game but I’m unsure how I would go about doing this. I have tried looking on the internet and DevForum but had no luck, does anyone know how I would do this?
Gradients use ColorSequence as color for the element. You can learn a little more about them here. I will inform you can not tween ColorSequences and you would probably have to make a custom system for that, but this is off topic.
2 Likes
Well, there’s pretty much infinite ways of making “color changing gradients”, but here’s an example:
local ANIMATE_SPEED = script:GetAttribute("AnimateSpeed")
local gradient = script.Parent
game:GetService("RunService").RenderStepped:Connect(function(dt)
local newKeypoints = {}
for i, oldKeypoint in pairs(gradient.Color.Keypoints) do
local oldH, oldS, oldV = Color3.toHSV(oldKeypoint.Value)
local newColor = Color3.fromHSV((oldH + ANIMATE_SPEED * dt) % 1, oldS, oldV)
newKeypoints[i] = ColorSequenceKeypoint.new(oldKeypoint.Time, newColor)
end
gradient.Color = ColorSequence.new(newKeypoints)
end)
Model file (drag/drop into studio):
GradientHueSweeper.rbxm (3.3 KB)
1 Like
I had a similar issue, which I ended up solving myself with advice from an old topic:
2 Likes