I need help subtracting the numbers from a Color3 value while tweening it

I want to subtract the game’s Lighting.Ambient value by 1 with a tween but for some reason, Color3 values don’t allow that??? It’s weird because I’ve seen code that does exactly what I’m trying to do but in a convoluted and un-tween-friendly way. Does anyone have any tips?

Here is the tween I’m trying to use (I know it doesn’t work, do not tell me it won’t work)

local brightnessTween = TweenService:Create(game.Lighting, TweenInfo.new(0.5), {Ambient = Lighting.Ambient - Color3.fromRGB(1,1,1)})
1 Like

The way a tween works is the stuff in {} is a goal, what the tween should slowly set that value towards. The way you’re trying to incorporate it, is as if its in a loop.

Here’s an example script.


local TweenService = game:GetService("TweenService")
local brightnessTween = TweenService:Create(game.Lighting, TweenInfo.new(0.5), {Ambient = Color3.fromRGB(255,255,255)})
brightnessTween:Play()

1 Like

There are Plenty of ways, here is one for Example:

local Ambient = Lighting.Ambient -- Gets Color3
local newColor = Color3.fromRGB(Ambient.R-1, Ambient.G-1, Ambient.B-1) -- Modifies Color3
local brightnessTween = TweenService:Create(Lighting, TweenInfo.new(.5), {Ambient = newColor})
-- I basically just Copy Pasted the Tween code from the Guy Above (lol)
1 Like

You can make a function to subtract color3s

local function subtractColor3(color : Color3, subtractor : Color3 | number)
	if (typeof(subtractor) == 'Color3') then
		return Color3.fromRGB(color.R - subtractor.R, color.G - subtractor.G, color.B - subtractor.B)
	elseif (type(subtractor) == 'number') then
		return Color3.fromRGB(color.R - subtractor, color.G - subtractor, color.B - subtractor)
	end
end
1 Like

Could you please mark my reply as a solution if it worked for you?