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.
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"))