I'm trying to make color sliders for my game. Originally, I was using RGB values, and everything was fine. However, I decided that HSV sliders might be better. So, when I changed all of the "Color3.new" to "Color3.fromHSV", it no longer worked, technically. The color value always output as (0, 0, 0). I believe this is because, while I can access Color3.r, g, and b, I can't access Color3.h, s, and v. This is a problem, because I only want to change one property at a time; one property is a variable, and the rest I would hypothetically want to use ImageColor3.s, or ImageColor3.v. How could I do something like this?
Here's the code, if it helps. Around line 28 is the problem in question. It works just fine if I switch Color3.fromHSV to Color3.new.
local UIS = game:GetService("UserInputService")
local RuS = game:GetService("RunService")
local slider = script.Parent.Slider
local bar = script.Parent
local held = false
local customcolor = script.Parent.Parent.CustomColor
function snap(number, factor)
if factor == 0 then
return number
else
return math.floor(number/factor+0.5)*factor
end
end
UIS.InputEnded:connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
held = false
end
end)
script.Parent.MouseButton1Down:connect(function()
held = true
end)
RuS.RenderStepped:connect(function(delta)
if held then
script.Parent.Parent.CustomColor.ImageColor3 = Color3.fromHSV(slider.Position.X.Scale, customcolor.ImageColor3.G, customcolor.ImageColor3.B)
local MousePos = UIS:GetMouseLocation().X
local pos = snap((MousePos-bar.AbsolutePosition.X)/bar.AbsoluteSize.X,0.02)
local percentage = math.clamp(pos,0,1)
slider.Position = UDim2.new(percentage,0,slider.Position.Y.Scale, slider.Position.Y.Offset)
wait()
end
end)

3 comments
S isn't Green, V isn't Blue
bump
Yeah, but S and V aren't real properties I can use.