Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a smooth and quick fade?

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

✓ Accepted answer

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()

2 comments

0

Thanks alot!

0

Your welcome! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.