Whats wrong with this tween?

not sure whats wrong with the tween, it just doesn’t wanna work

local ts = game:GetService("TweenService")
local tween
local tweeninfo
local goal = {}
local colors = {{255,0,0}, {255,120,0}, {255,255,0}, {0,255,0}, {0,174,255}, {0,0,255}, {80,0,255}, {170,0,255}, {255,0,213}}
-- red, orange, yellow, green, light blue, blue, purple, violet, pink

for	i, v in ipairs(colors) do
	print(i, v)
	goal.TextColor3 = Color3.new(v[1], v[2], v[3])
	
	tweeninfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, false, 1)

	tween = ts:Create(script.Parent, tweeninfo, goal)

	tween:Play()
	tween.Completed:Wait()
end

Are you trying to loop through colors to make a rainbow? If so I recommend taking a different approach then TweenService. I’d personally run a loop like this:

local t = 5 --adjust this number for the speed you want
while task.wait() do
	local h = tick() % t / t
	local color = Color3.fromHSV(h, 1, 1)
        script.Parent.TextColor3 = color
end
4 Likes

hm, but wouldn’t this only change the color in what area?
(also sorry for the late reply)

From what I can see on the official roblox developer documentation, and testing it in-game myself, the first value (hue) is essentially just a value that determines the colour with a value from 0-1 within the RGB spectrum, the other two values are saturation and value, which are meant more for brightness, replacing the saturation and value gave me a dimmer colour, ending with black and restarting from a dim red.
Though it does seem to work for what you need.

1 Like

oh, after i read what you said i realized i was using color3.new instead of color3.fromhsv
thanks for helping me out

local Game = game
local RunService = Game:GetService("RunService")

local Colors = {Color3.new(1, 0, 0), Color3.new(1, 0.5, 0), Color3.new(1, 1, 0), Color3.new(0, 1, 0), Color3.new(0, 0, 1), Color3.new(0.5, 0, 1), Color3.new(1, 0, 1)}

local function LerpRainbow(Object, Property, Time)
	for _, Color in ipairs(Colors) do
		local StartTime = RunService.Stepped:Wait()
		while true do
			local CurrentTime = RunService.Stepped:Wait()
			if (CurrentTime - StartTime) > (Time / #Colors) then break end
			Object[Property] = Object[Property]:Lerp(Color, (CurrentTime - StartTime) / (Time / #Colors))
		end
	end
end
1 Like