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

01local label = --textlabel here
02local startColor = Color3.new(1,0,0)
03local endColor = Color3.new(0,0,1)
04local tweenTime = 1
05 
06label.BackgroundColor3 = startColor
07local goal = {}
08goal.BackgroundColor3 = endColor
09local info = TweenInfo.new(tweenTime)
10local tween = game:GetService("TweenService"):Create(label,info,goal)
11while true do
12    tween:Play()
13    tween.Completed:Wait()
14end

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

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

Answer this question