How do i generate different shades of a colour?

Hi, I have a model containing parts, and I want the colours to be different shades of blue, wondering how you would do it.

In other words, I want each part to have a different shade of blue like this:
image

You can try using Color3.fromHSV() where Hue represents the Color, Saturation represents how “white” your color is, and Value represents how bright your color is. An example of this in code:

local function PickRandomColorShade(Hue: number): Color3
    return Color3.fromHSV(Hue, math.random(100) / 100, math.random(100) / 100)
end

print(PickRandomColorShade(0.666667)) -- '0.666667' would be the hue for Blue
1 Like

Now we are getting somewhere! Thank you, I tried this out in a loop, and it works ok, I noticed different shades of black and white though, all I’m looking for is different shades of blue, so maybe I would change some numbers or something? If so – how would I make it more limited to just different shades of blue, dark blues, light blues, etc?

This is just a result of how Color3.fromHSV works! If you strictly want blue shades and would like to hide the clearer Black/White colors, just change the function to this :wink:

local function PickRandomColorShade(Hue: number): Color3
    return Color3.fromHSV(Hue, math.random(70) / 100, math.random(30, 100) / 100)
end

print(PickRandomColorShade(0.666667)) -- '0.666667' would be the hue for Blue
1 Like

Perfect, works fantastic, thank you very much!

Also just out of curiosity, if I wanted to have for example different shades of red or yellow or something, what would I change to achieve that effect?

1 Like

For different colors, change the hue value that you’re giving into the function. You can find Color Hue’s by playing around with a Color3 in your script. Heres an example:

RobloxStudioBeta_emHqIhfnWu

1 Like

Oh wow, thank you so much! I would of never of known that haha.

1 Like

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