You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I would like to be able to change the HUE of the GUI, without touching the other values
What is the issue? Include screenshots / videos if possible!
It first changes the color to random ones, then stop changing them after a few scroll.
I added the D variable cause i thought i was scrolling too fast, but that wasn’t the issue.
--Variables
local Main = script.Parent.Main
local Rainbow = script.Parent.Rainbow.ScrollingFrame
local D = false
--Rainbow Moved
Rainbow:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
if D == false then
D = true
local Code = Rainbow.CanvasPosition.Y/252734
local Color = Main.BackgroundColor3
Main.BackgroundColor3 = Color3.fromHSV(359*Code, Color.G, Color.B)
wait(0.3)
D = false
end
end)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried searching around, found nothing
You’re using the Green and Blue components of the existing color as Saturation and Value.
You can use Color3.ToHSV() to get Saturation and Value of the existing color.
--Variables
local Main = script.Parent.Main
local Rainbow = script.Parent.Rainbow.ScrollingFrame
local D = false
--Rainbow Moved
Rainbow:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
local Code = Rainbow.CanvasPosition.Y/252734
local Color = Main.BackgroundColor3
Main.BackgroundColor3 = Color3.fromHSV(Code, 1,1)
end)
To set the hue of a Color3 you can use Color3.fromHSV(<hue>, 1, 1) where <hue> is a number between 0 and 1.
To get the current hue you can use Color3.ToHSV().
E.g.
local function shiftHue(color: Color3, hueShift: number): Color3
local hue, saturation, value = color:ToHSV() -- get current hue
hue = hue + hueShift -- change hue by hueShift amount
hue = hue % 1 -- make sure value rolls over >1 to stay within 0-1
return Color3.fromHSV(hue, saturation, value) -- return Color3 with new hue
end
local color = Color3.fromHSV(0, 1, 1) -- create starting color
local hueShift = 0.05 -- you can use any value between 0-1
color = shiftHue(color, hueShift) -- shift hue of color
If you don’t understand this I highly recommend reading the documentation for both Lua and the specific Roblox objects you’re trying to use.