Smooth lerping between two Colours

Ok, so: I am working on a game and I need atmosphere for this, but something don’t work.

I need have cyan colour and a black colour. Lets say cyan is the atmosphere of the earth and black is the space. So, now I tried to move from cyan to black using this code on a part:

local function lerp(a, b, c) --This is the regular lerp function, don‘t ask me how it works it‘s just this
    return a + (b - a) * c

local Hue, Saturation, Value =, 253, 255):ToHSV()
local part = workspace.Part
while true do
    for i = 0, 1, 0.1 do
        part.Color = Color3.fromHSV(Hue, Saturation, lerp(Value, 0, i))

    for i = 1, 0, -0.1 do
        part.Color = Color3.fromHSV(Hue, Saturation, lerp(0, Value, i))


What am I doing here? I first get my colour, the Cyan colour. Then I port it from the RBG system to the HSV system. Why? Because I thought it would be much easier to use the lerping. Here is a picture with my main motive:
You can see that if the Value is at 0 then the colour is black, but if it is at 255 then the colour will be the acctua colour. You can even see the smooth transition between cyan and black.

Now, what‘s my problem? My problem is that my code just dosen‘t work and I don‘t know why. It is my first time that I need to do something like this and I not really know much about colours. So, the part just change it colour to red, darkblue, pink, orange, yellow and black, but I just wanted that it changes from cyan to black, like in the image. Lets get again the example with the atmosphere. I think that if you would go to the space then the atmosphere would change it‘s colour from cyan to black, not from cyan to pink, yellow, orange, etc. and then black.

@RoyStanford helped me to understand what @gillern was trying to say me, you should see his reply, too:

1 Like

Wow sounds like this recent resource/tutorial on using an HSV color map should come in handy for this scenario. takes values from 0-1, not 0-255

Color3.fromRGB() takes values from 0-255

Color3.fromHSV() takes values from 0-1


Wow thanks, I will try asap! But there is something that can‘t work: The Wiki page is false, because: try this code:

local CyanColor =, 254, 255)
local Hue, Saturation, Value = CyanColor:ToHSV()
print(Value) --255

The result will be 255, wich isn‘t between 0 and 1. The Hua and Saturation is between 0 and 1, but the Value not. Idk if this is the cause of my problem, but if I want to use these Values to create an RBG colour using the .fromHSV() function, then I will get the exact same colour, so this shouldn‘t be a problem.

Why are you multiplying the percentage by 120/360? And why are the two last parameters that what they are?

And I still don‘t understand what is my problem.

Unless I’m reading your post wrong can’t you just use Color3:lerp()?

colorA:lerp(colorB, lerpProgress)

If I use the lerp function, then I won‘t go directly from cyan to black but I will pass other colors that are on the way. And I don‘t want this. Again read my post

Do you see the Value arrow? At 0 it is black ad at 255 it is the normal colour.

What are else the consequences? The consequences are that the lerping dosen‘t will work correctly, so the colours traveled won‘t be the right.

What you are saying to do is the same thing that colbert2677 said

But it isn‘t good.

Oh okay. @gillern solved your problem though. Change:, 253, 255)

to, 253/255, 255/255)

Sorry but I still can‘t understand how I can lerp. The whole problem is that I need to lerp from the colour A (cyan) to colour B (black). What you are doing is that you are transforming my values to scales. But…

EDIT: Nope, nevermind. I just am dumb at 100%. Like @gillern said, accept only numbers beetween 0 and 1, I just changed constructor from new to fromRBG. Now it‘s working without any issues. Thanks again @RoyStanford, I am just sorry that I can‘t assign 2 solutions, so I will quote you on the topic. Thanks again for helping me, and thanks to all the people that helped me.

1 Like