I tried using the :TweenTransparency but it doesnt work can i get help?
Is it possible to tween a GUIs transparency?
2 answers
Yes it is possible to tween transparency of a GuiObject however, you're doing it wrong.
First of all, GuiObject:TweenTransparency() doesn't exist. I see you might have come to such a conclusion seeing the GuiObject:TweenSize(), GuiObject:TweenPosition() and the GuiObject:TweenSizeAndPosition() methods but these three are the only tween related methods.
Tweening
Now to write the script itself, we'll have to learn a bit about tweening itself. Tweening in Roblox is done through the TweenService service and it's TweenService:Create(Instance, tweenInfo, propertyTable) method. Instance here is the Instance you aim to tween property/properties of.
tweenInfo
TweenInfo holds the information about your tween such as duration, type of tween, looping of tween, etc. TweenInfo uses a constructor which is TweenInfo.new(time, easingStyle, easingDirection, repeatCount, reverses, delayTime). time (number) is the time in seconds the tween should last for (default 1 second), easingStyle (Enum) is the easing style the tween will use (default Linear style), easingDirection (Enum) is the easing direction the tween will use (default Out direction), repeatCount (number) is the number of times the tween will repeat after tweening once (default 0 times), reverses (bool) is whether the tween will reverse tween after the original tween (default false), delayTime (number) is the number of seconds the tween will wait after being played to start (default 0 seconds)
Since some of these might be new to you, here is some deeper explanation:
easingStyle
easingStyle is the style of tweening used to reach the goal. The many tweening styles are seen in the wiki, here's an example of all the tweening styles:
Each of the shown frames are tweened with the easing style it represents. Easing styles are enums which means the input for the Bounce easingStyle will be either "Bounce" or "Enum.EasingStyle.Bounce"
easingDirection
easingDirection is "the direction in which the EasingStyle executes". The easingDirections "In" and "Out" are observed with each easingStyle in the wiki and the GIF above. Easing directions are also enums which means the input for the In easingDirection will be either "In" or "Enum.EasingDirection.In" (ignore the hyperlink, .in formatted it that way)
Example
For a tween that lasts 2 seconds and uses the bounce easing style when it is reaching the end, one can use the following tweenInfo:
TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out)
-- Notice that the last three paramters aren't listed as their default value suits the situation
propertyTable
The propertyTable is a dictionary that holds the target value of each property as defined in it. The wiki says that the tweenable types of values are:
- number
- bool
- CFrame
- Rect
- Color3
- UDim
- UDim2
- Vector2
- Vector2int16
- Vector3
The format of the propertyTable is:
local goal = {
PropertyName = valueOfProperty;
PropertyName = valueOfProperty;
}
or alternatively, you can use:
local goal = {}
goal.PropertyName = valueOfProperty
Example
To set the goal of a part's tween to a position of 0, 7, 3 and it's reflectance to 0.6 the following propertyTable can be made:
local goal = {}
goal.Position = Vector3.new(0, 7, 3)
goal.Reflectance = 0.6
Creating and playing a tween
After a creating a tween it's essential to play the tween so it may run on whatever instance it is supposed to be played on.
local tween = game:GetService("TweenService"):Create(Instance, tweenInfo, propertyTable)
-- After whatever triggers the tween to play
tween:Play()
You can also use the tween:Cancel() method to cancel a tween midway and the tween:Pause() method to pause a tween and usetween:Play() again to resume said paused tween
Finally to tween a GUI's transparency you can use the following:
local toTween = yourGuiObjectHere
local tweenInfo = TweenInfo.new() -- Change to your liking
local goal = {}
goal.BackgroundTransparency = 1 -- Change to your liking
local tween = game:GetService("TweenService"):Create(toTween, tweenInfo, goal)
-- Add this wherever you want the tween to play
tween:Play()
Useful links:
- https://developer.roblox.com/api-reference/class/Tween
- https://developer.roblox.com/api-reference/function/TweenService/Create
- https://developer.roblox.com/api-reference/class/TweenService
- https://easings.net/en
- https://developer.roblox.com/api-reference/datatype/TweenInfo
I might have made mistakes here and there, be sure to comment and correct me or ask any questions you may have
A GUI has a property where you can choose whether the frame is visible totally or if it is totally invisible. Here is an example:
script.Parent.Visible = true
The script above would make the GUI (the scripts parent in my case) fully visible. If I set this to false then it would not be visible.
I don't believe i is currently possible to tween the transparency of a GUI.
2 comments
LOL
dude you answered this after there was proof of it being possible. >:[
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Thanks. Bet you have spent a long time
It is possible to tween practically anything with TweenService.
Very good explanation, thank you.