Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Color3 lerp like a ramp?

So far I have this but it just sets it to the b color. I don't know what to do.. if color3 doesn't have an alpha. How would I achieve this?

Basicly trying to ramp white to red base off t

local GUI = game.StarterGui.ScreenGui
local frame = GUI:WaitForChild("Frame")

function lerp(a, b, t)
    t = math.clamp(0, 1, 1)
    return Color3.new(
        a.r + (b.r - a.r) * t,
        a.g + (b.g - a.g) * t,
        a.b + (b.b - a.b) * t
    )
end

frame.BackgroundColor3 = lerp(Color3.fromRGB(255,255,255), Color3.fromRGB(255,35,35), 0.5)

3 comments

0

I forgot that clamp rounds your number.. :P

0

it doesn't, Color3.new just takes values from 0 to 1 but you're lerping it from 0 to 255

0

nope, it works just as it should, the math.clamp round 0.5 to 1

1 answer

Answer: Just remove t = math.clamp(0, 1, 1), and make sure t is from 0 - 1

This discussion is preserved as it was. New answers, comments, and votes are closed.