Need help with making colours darker on certain UIs

I want to code something that would allow me to change the colour of a player’s theme, I already coded that part but the problem is that when a UI instance has a darker TextColour, it will cause issues because the colour you pick from the palette will be the colour for every UI instance, but for the darker ones I want it to be the colour you pick but a darker version, how can I implement this?

Here are some screenshots to make things clear.
image

As you can see the white texts will be changed to the theme colour, but the texts underneath them are grey, I want it to change to the theme colour but a darker version of it.

I’ve tried asking it on helping servers, but nothing answers my question.

local function exampleColour(hsv)
	for i,v in pairs(hud:GetDescendants()) do
		if v.Name == "IsTheme" then
			if v.Parent:IsA("TextLabel") or v.Parent:IsA("TextButton") then

				local lerp = hsv:Lerp(Color3.fromHSV(hsv.R,hsv.G,hsv.B),Color3.fromHSV(v.Parent.TextColor3.R,v.Parent.TextColor3.G,v.Parent.TextColor3.B),0.5)

				local dark = script.Dark:Clone()
				dark.TextColor3 = lerp
				dark.TextTransparency = 0.5
				dark.Parent = v.Parent
				v.Parent.TextColor3 = hsv
			end
		end
	end
end
1 Like

What is the hsv parameter? Why are you using the rgb components as inputs to fromHSV?

Never mind, I already figured this out!

How did I do it?
I simply added a Number value called “Multiply”, so every colour that will be assigned to every UI instance will be multiplied with that value as RGB, like if I have a 0.5 value the colour of that ui instance’s darkness will be the half
Here’s the code so some of you might understand it better:

local function exampleColour(hsv)
	for i,v in pairs(gui:GetDescendants()) do
		if v.Name == "IsTheme" then
			if v.Parent:IsA("TextLabel") or v.Parent:IsA("TextButton") or v.Parent:IsA("ImageLabel") or v.Parent:IsA("UIStroke") then
				local typ
				if v.Parent:IsA("TextLabel") or v.Parent:IsA("TextButton") then
					typ = "TextColor3"
				end
				if v.Parent:IsA("ImageLabel") then
					typ = "ImageColor3"
				end
				if v.Parent:IsA("UIStroke") then
					typ = "Color"
				end
				local multiply = v:FindFirstChild("Multiply")
				local r,g,b = math.floor((hsv.R*255)+0.5),math.floor((hsv.G*255)+0.5),math.floor((hsv.B*255)+0.5)
				
				rgb = Color3.fromRGB(r*multiply.Value,g*multiply.Value,b*multiply.Value)
				
				v.Parent[typ] = Color3.fromRGB(r*multiply.Value,g*multiply.Value,b*multiply.Value)
			end
		end
	end
end

You should share the solution you found so others looking for help on similar problems can find it!

Done! I have typed out how I solved this issue.

1 Like