So in my obby there is a gui that will appear every time your stage changes. I want this gui to have a smooth transition when it appears and disappears. I cant’t figure out how to have a smooth transition but I figured out how to make it appear when your stage changes.
I do not know how I would script a smooth transition that would show every time your stage changes. My code:
local cool = game:GetService(“Players”).LocalPlayer
local stat = cool:WaitForChild(“leaderstats”).Stage
stat.Changed:Connect(function(value)
local leader = stat.Value
script.Parent.Text = “Stage “..leader
-- i want this to be a smooth transition which i think i can do with script.Parent.TextTransparency += 0.05
script.Parent.TextTransparency = 0
wait(0.5)
script.Parent.TextTransparency = 0.1
wait(0.5)
script.Parent.TextTransparency = 0.2
wait(0.5)
script.Parent.TextTransparency = 0.3
wait(0.5)
script.Parent.TextTransparency = 0.4
wait(0.5)
script.Parent.TextTransparency = 0.5
wait(0.5)
script.Parent.TextTransparency = 0.6
wait(0.5)
script.Parent.TextTransparency = 0.7
wait(0.5)
script.Parent.TextTransparency = 0.8
wait(0.5)
script.Parent.TextTransparency = 0.9
wait(0.5)
script.Parent.TextTransparency = 1
I’ve tried making a smooth transition with the above but it isn’t really smooth. Any help on how I can make the TextTransparency of my TextLabel to be smooth. Also here is the game if anyone needs to see the transition rn
Learn TweenService! It’s designed exactly for this, and allows for an extremely customizable transition between two property values. In your case, I would use the following code:
local cool = game:GetService(“Players”).LocalPlayer
local stat = cool:WaitForChild(“leaderstats”).Stage
stat.Changed:Connect(function(value)
local leader = stat.Value
script.Parent.Text = “Stage “..leader
script.Parent.TextTransparency = 0
game:GetService("TweenService"):Create(script.Parent,TweenInfo.new(5),{TextTransparency = 1}):Play()
You can find the Documentation for TweenService here: Link
If you can’t understand it yet, that’s completely fine! I would recommend going on YouTube and searching it up. I ususally do that when the docs are too complicated. Hope this helps!
local Frame = script.Parent
local TweenService = game:GetService("TweenService")
local Goal = {} -- goal of the tween... like what you want it to do
Goal.BackgroundTransparency = 0
local Settings = TweenInfo.new( -- where you customise your tween
1, -- duration
Enum.EasingStyle.Linear, -- how it will look
Enum.EasingDirection.InOut, -- how it will start and end
0, -- repeats
true, -- reverses when tween ends
1 -- delay time
)
local Tween = TweenService:Create(Frame, Settings, Goal)