How can I find the median of 2 color values using only code?

I’m trying to find a way to find the median of 2 color3 values using only code, but I have not found a way to do so.

I’ve tried using tweens and stopping it mid way to get the color value, but it’s inconsistent.

local tweenService = game:GetService("TweenService")
local debris = game:GetService("Debris")

function getMedianColor(color1,color2)
	local new ="Part")
	new.Parent = workspace
	new.Color = color1
	local tween = tweenService:Create(new,,{Color = color2})
	return new.Color

--Expected output = 0.5,0.5,0.5

How can I make a consistent way to get the median color?

Try something like this:

local R1=0
local G1=0
local B1=0

local R2=1
local G2=1
local B2=1

local MedianColor =,(G1+G2)/2,(B1+B2)/2)

You could also try local MedianColor = (,1,1),0,0))/2, Though I am not sure if that works.

This is actually a pretty bad way to do it, I strongly suggest looking into Color3:Lerp()


After looking at this, yes, this is a better solution.

1 Like

I Actually never knew that there was a Color3:Lerp(), I only ever saw Vector3:Lerp() and CFrame:Lerp()

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