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

How to make a smooth and quick fade?

Asked by 4 years ago

Usually i'd do something like

for i = 0,1,.1 do
    frame.BackgroundTransparency = i
    wait(0.0001)
end

but that makes the fade look all blocky and not right. I've seen some games make a fade even smoother than what i just mentioned. Question is how do they do it?

1 answer

Log in to vote
0
Answered by 4 years ago

TweenService is always a good go-to when your trying to make something tween smoothly in and out.

Try something like this:

local TS = game:GetService("TweenService")
local Frame = script.Parent

local function tweenBackground()
    -- More about TweenInfo here: 
    -- https://developer.roblox.com/en-us/api-reference/datatype/TweenInfo
    TS:Create(Frame, TweenInfo.new(
        1, -- Time it takes.
        Enum.EasingStyle.Quad, -- Easing style.
        Enum.EasingDirection.Out -- Easing direction
    ), {BackgroundTransparency = 1}):Play()

    -- If you want the frame to dissapear, set BackgroundTransparency = 1.
    -- If you want the frame to appear, set BackgroundTransparency = 0.
end
tweenBackground()
0
Thanks alot! FrankyLovesGames 35 — 4y
0
Your welcome! :) DeveloperColton 229 — 4y
Ad

Answer this question