Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with tweening Colors on textlabels ?

Asked by 6 years ago

Hi, I looked all ovee the wiki but can't find anything, how do I tween a text label to change color smoothly and I don't want it to stop, if you can help it will help thanks.

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

You can use TweenService to intepolate the colour of the gui from one colur to another over a given period of time.

For example:

local label = --textlabel here
local startColor = Color3.new(1,0,0)
local endColor = Color3.new(0,0,1)
local tweenTime = 1

label.BackgroundColor3 = startColor
local goal = {}
goal.BackgroundColor3 = endColor
local info = TweenInfo.new(tweenTime)
local tween = game:GetService("TweenService"):Create(label,info,goal)
while true do
    tween:Play()
    tween.Completed:Wait()
end

Or, if you wanted it to cycle through all of the colours, you could simply do something like this:

while true do
    for i = 1,255 do
        label.BackgroundColor3 = Color3.fromHSV(i/255,1,1)
        wait()
    end
end
Ad

Answer this question