How do you Tween more than one color/two times of the same property?

Hello! So I wanted to know if it’s possible to tween the same property twice but with different value for example (in which I need help of), I want to change a TextColor to let’s say red, but then change it to blue and then to pink etc. but for some reason I can’t find of a solution for that, so I am asking if it’s possible to tween more than two of the same properties with different values. If yes, please show me how to do that. I appreciate any help!

local NameTag = script.NameTag
local TweenService = game:GetService("TweenService")

local ti = TweenInfo.new(
	1,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut,
	-1,
	false,
	0
)

-- Here I store the color
local colors = {
	Color3.fromRGB(255, 0, 4),
	Color3.fromRGB(30, 0, 255),
	Color3.fromRGB(255, 56, 255)
}


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		repeat wait() until character:WaitForChild("Head")
		local plrTag = NameTag:Clone()
		local Stage = player.leaderstats.Stage
		character:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
		plrTag.PlayerName.Text = player.Name
		if Stage.Value < 6 then
			plrTag.PlayerRank.Text = "Beginner"
		elseif Stage.Value >= 6 and Stage.Value < 11 then
			plrTag.PlayerRank.Text = "Explorer"
		elseif Stage.Value >= 11 and Stage.Value < 20 then
			plrTag.PlayerRank.Text = "Climber"
			for _, color in ipairs(colors) do -- this is what I am trying to do
				local propertyTable = {TextColor3 = color}

				local tween = TweenService:Create(plrTag.PlayerRank, ti, propertyTable)
				tween:Play()
				tween.Completed:Wait() -- Wait for the tween to complete before changing to the next color
			end
		end
		print(Stage.Value)

		plrTag.Parent = character.Head
	end)
end)
1 Like

That looks like it should work. Are you sure it is starting?

1 Like

It does work, but the problem is, it only tweens the color red, not blue or pink or any other color. There is also no error in the output
Here is some video material:

1 Like

Maybe replace your tweeninfo with this local ti = TweenInfo.new( 1, Enum.EasingStyle.Linear, Enum.EasingDirection.In

1 Like

This now only worked for the last variable (pink, no transition) and as soon as I put -1 for a repeat count, it immediately only tweens the color red

1 Like

I tested this on a part and it worked fine

local colors = {
	Color3.fromRGB(255, 0, 4),
	Color3.fromRGB(30, 0, 255),
	Color3.fromRGB(255, 56, 255)
}

local TweenService = game:GetService("TweenService")

local ti = TweenInfo.new(
	1,
	Enum.EasingStyle.Linear,
)

for _, color in ipairs(colors) do -- this is what I am trying to do
	local propertyTable = {Color = color}

	local tween = TweenService:Create(game.Workspace.Tween, ti, propertyTable)
	tween:Play()
	tween.Completed:Wait() -- Wait for the tween to complete before changing to the next color
end


1 Like

Hm, I don’t know why this doesn’t work on TextColor3 then

2 Likes

That did work as well for text color

1 Like

I see the issue here. For the TweenInfo repeat count, you set it to -1, causing the first tween (black to red) to tween infinitely, never stopping and just resetting over and over. To fix this just change the -1 to 0 and you should be good to go.

Ik its only a screenshot, but this is what happens, its stuck at pink

image

1 Like

This is because the for loop only repeats once, so once it reaches the last color it will end. You can just put the for loop into a while loop to fix that.

2 Likes

Thank you dolphin, this helped! It now works completely fine thank you for your help and thank you Bob and I will remember this from now on!

2 Likes

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