Struggling to change property of ColorCorrection.TintColor with TweenService?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would need the ColorCorrection to have a rainbow tint that changes colors (with tweenservice)

  2. What is the issue? Include screenshots / videos if possible!

There’s an issue with the current rainbow script that I use for most of my building parts, it somehow doesn’t work for “colorcorrection”, I am sure that it should be the “tintcolor” that I’m supposed to cast the value on, but for some reason it says “unable to cast value to object”

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried removing the whole “colortint” and direct the tween to “game.workspace.colorcorrection” and also instead of using “color.fromrgb” to others, but it just doesn’t seem to work at all
I did look for "unable to cast value to object or anything related to “ColorCorrection rainbow” (I’m quite straightforward when I look for these things lol), but nothing seems to help

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local TS = game:GetService('TweenService')
local Colors = {{255, 125, 0}, {255, 255, 0}, {125, 255, 0}, {0, 255, 0}, {0, 255, 125}, {0, 255, 255}, {0, 125, 255}, {0, 0, 255}, {125, 0, 255}, {255, 0, 255}, {255, 0, 125}}

local tweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In
)





local function initiateColorChange(part)
	while true do
		wait()
		for i = 1, #Colors do
			local NextColor = TS:Create(part, tweenInfo, {Color = Color3.fromRGB(unpack(Colors[i]))})
			NextColor:Play()
			NextColor.Completed:Wait()
		end
	end
end


if true then
	local ColorTint = game.Lighting.ColorCorrection.TintColor
	initiateColorChange(ColorTint)
	wait()
end

This is because you are setting the wrong property in TweenService:Create

try this

local TS = game:GetService('TweenService')
local Colors = {{255, 125, 0}, {255, 255, 0}, {125, 255, 0}, {0, 255, 0}, {0, 255, 125}, {0, 255, 255}, {0, 125, 255}, {0, 0, 255}, {125, 0, 255}, {255, 0, 255}, {255, 0, 125}}

local tweenInfo = TweenInfo.new(
	5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.In
)


local function initiateColorChange(part: ColorCorrectionEffect)
	while task.wait() do
		for _, Color in Colors do
			local tween = TS:Create(part, tweenInfo, {
				TintColor = Color3.fromRGB(table.unpack(Color))
			})
			
			tween:Play()
			tween.Completed:Wait()
		end
	end
end


if true then
	local ColorTint = game.Lighting.ColorCorrection
	initiateColorChange(ColorTint)
	wait()
end

Thank you for your help, I actually never realised that ColorTint was the issue there
No wonder why it didn’t go through

I’ll keep in mind that if anything goes wrong again that’s also a factor to check :slight_smile:

No problems! You were passing in a number that was equal to TintColor, which is why the error occurred.

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