num is a number between 0 and 1. I wrote the function based on this rgb color wheel picture I found on the internet. But why don’t you want to use Color3.fromHSV?
local function getPositiveAngleDiff(a, b)
return a < b and a+360-b or a-b
end
-- returns r, g and b
local function getRainbowRGB(num)
local angle = num*360
local components = {}
for i = 1, 3 do
local startAngle = ((i+1)*120)%360
local diffFromStart = getPositiveAngleDiff(angle, startAngle)
if diffFromStart < 60 then
components[i] = diffFromStart/60*255
elseif diffFromStart <= 180 then
components[i] = 255
elseif diffFromStart < 240 then
components[i] = (240-diffFromStart)/60*255
else
components[i] = 0
end
end
return components[1], components[2], components[3]
end