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)
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:
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
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.
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.