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

How do you tween a UI Object's transparency?

Asked by 4 years ago

So I want to use TweenService to get a smooth fade out and in, but I can't remember how you use tweens to change a background transparency. Any help is appreciated.

2 answers

Log in to vote
0
Answered by 4 years ago
1local Frame = script.Parent -- Define your UI Object
2 
3TweenService:Create(Frame, -- Name of your UI Object
4    TweenInfo.new(1), -- Amount of time it takes for the tween to complete
5    {BackgroundTransparency = 0}) -- Goal; what you want the tween to do
6    :Play()
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Like you would any other property.

1local tweenSrv = game:GetService('TweenService')
2 
3local tween = tweenSrv:Create(--[[Your GUI object]], TweenInfo.new(
4    --[[ Amount of time it will take for the tween to complete ]],
5    --[[ Easing style ]],
6    --[[ Easing direction ]],
7    -- The other parameters if you need them
8), {BackgroundTransparency = --[[ The value of which this property should be set to when the tween ends ]] })

Answer this question