How to use integer colors with frame colors?

Hi!

I am currently using an api to return discord roles. The color of the role returns a decimal (ex; 3093151). I would like to try and set that as the button color, so how would I go about turning that decimal color into an r,g,b color and making it the color of the button.

Thanks in advance!

Are you sure that’s not a hexadecimal that just doesn’t have letters?

what api are you using and what are the options

If the “decimal” Discord is returning is actually a hexcode, you can use this code to convert to a Color3 via RGB:

local function hexcodeToRgb(hex)
	local components = {}
	for hexcomponent in hex:gmatch("%w%w") do
		table.insert(components, "0x" .. hexcomponent)
	end
	
	return Color3.fromRGB(
		tonumber(components[1], 10),
		tonumber(components[2], 10),
		tonumber(components[3], 10)
	)
end

print(hexcodeToRgb("309315"))
1 Like

Thank you so much! I will try it.