How to get HSV values of Color3?

How can I get the hsv values equal to those that appear in the roblox studio colopicker?

local color = Color3.new(0, 1, 0)

local h, s, v = color:ToHSV() -- return { 0.33333~. 1, 1 }

image

3 Likes

not sure that’s the correct answer, the OP said the H returned 1/3 and i’m pretty sure the january third of 255 isn’t even close to 212

1 Like

hue is a degree value between 0-360

h*=360
1 Like

Oops, this code should work:

local color1 = Color3.fromHSV(0.997389, 1, 1) -- HSV: 359, 255, 255
local color2 = Color3.fromHSV(0.322833, 1, 0.498039) -- HSV: 116, 255, 127

function getHSV(color: Color3)
	local h, s, v = color:ToHSV()
	h = math.round(360 * h)
	s = math.round(255 * s)
	v = math.round(255 * v)
	return h, s, v
end
print(getHSV(color1))
print(getHSV(color2))

@p49p0 I’m not sure why OP used a different color for each, you can even see that the RGB components don’t match up.

2 Likes

Do you know how to fix this?

local color = Color3.fromHex('FF9605')
local h, s, v = color:ToHSV()

print(Color3.fromHSV(h, s, v):ToHex()) -- idk why return 'FF9604'
1 Like

That is just how Roblox works nothing much you can do about it. + its only a change in one digit you dont need to be SO precise.

This is a known bug

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.