3 ways to create Fade In and Out transitions - Color Correction Tweening

Introduction:

A wide variety of games use Screen Transitions such as Intros, loading screens, and normal transitions (teleporting for example).

In this topic, You’ll find 3 methods of Fade In and Fade Out transitions using tween service, and color correction effects. And how to simply use them (For one player, or multiple).

Secondly,

Color Correction Tweening is much Simpler than Tweening a GUI, and easier to use.

Pros:

  1. Shorter Code.
  2. Free mouse movement (Mouse gets stuck in first person using a GUI)
  3. Easy access to the tweened object.
  4. No pre-messing with properties (Such as size, transparency, Color)
  5. No messing with the TopBar Gui

Cons:

  1. Name-tags are visible when the screen is dark.
  2. Less customizable, no text/images unless using external GUI.

Final Result:

Main Fade-in/Out:

Fade-In/Out on Touch

Fade-In/Out on Death

Resources Used:

Tween Service
Color Correction Effects

Why use ModuleScript?

The reason is to shorten the code;
Easily access the function from both server and client.
I’ve decided to remove that from the resources as this is not a must.

Tutorial:

There are 3 options to accomplish transitions using this method.:

Which one to use is up to you.

Which one should I use?

It depends on your needs:

If you only need Fade-out/in with Black/Dark colors, or a non-Fade-in/out transition, use Option 1

If you only need Fade-out/in with Black/White, use Option 2

If you want transitions with selectable color, use Option 3

Step 1 (For all Options):

Open up the explorer and create a ColorCorrectionEffect in Lighting
‏‏CCE
Note: If you have multiple ColorCorrection effects, just name this one accordingly, I will name mine FadeInOut.

Step 2:

Create any type of script to your preference, and parent (locate) it accordingly.
I used a ModuleScript to easily access the function both from the client and the server. I called my Module Script Transitions and placed it in ReplicatedStorage.

Just remember, you can use server/local scripts, it’s much easier to not repeat yourself and use functions.
Tutorial1

Step 3:

Let’s get to coding! :cowboy_hat_face:
This step is divided into the 3 options, just pick the one you use.
The Tint color just changes the color and the brightness can make everything dark before the Fade-Out is done.
As I know, you can’t make a white Fade-Out but using the TintColor, correct me if I am wrong.
So with the brightness, you can make white Fade-Outs too.

But the third way, you can fully customize the color of your Fade-Out, but to get the right color, you need to change the brightness to the one that fits your color.
Let’s go to the script now.

Option 1: Tween the TintColor

In this option, we use 2 functions: Fade-In and Fade-Out.
In each function, we tween the TintColor using TweenService to the desired color (Black and White)

Further explanations can be found in the code:

local module = {}

local TweenService = game:GetService("TweenService") --Define the tween service.

module.FadeOut = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {TintColor = Color3.fromRGB(0,0,0)} --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

module.FadeIn = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)  --Tween settings
	local goal = {TintColor = Color3.fromRGB(255,255,255)}  --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

return module

Only black Fade-Out, you can change the color but it will look not fully solid.

Option 2: Tween the Brightness

In this option, we use almost identical 2 functions: Fade-In and Fade-Out.
In each function, we tween the Brightness using TweenService to the Brightness (Black and White, or transparency)

Further explanations can be found in the code:

local module = {}

local TweenService = game:GetService("TweenService") --Define the tween service.

module.FadeOut = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {Brightness = -1} --Our property goal 
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

module.FadeIn = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)  --Tween settings
	local goal = {Brightness = 0} --Our property goal 
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

return module

Only black Fade-Out, you can change the Brightness according to the transparency you want to achieve.

Option 3: Tween both TintColor and Brightness

In this option, we only use 1 function that creates the transition with the brightness and input we decided. (The function parameters).

local TweenService = game:GetService("TweenService") --Define the tween service.

local module = function(object, bright, color) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {Brightness = bright; TintColor = color } --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end
--When you call this function, you have to provide it the ColorCorrection object, the Brightness value, and the TintColor color.

return module

How to use:

To use this, you can just call the module function from any script/local script.

Note: If you're not using a ModuleScript, your code should look like this:
Option 1: Tween the TintColor
local transitions= {}

local TweenService = game:GetService("TweenService") --Define the tween service.

transitions.FadeOut = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {TintColor = Color3.fromRGB(0,0,0)} --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

transitions.FadeIn = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)  --Tween settings
	local goal = {TintColor = Color3.fromRGB(255,255,255)}  --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

------How to use:
local colorCorrectionObject = game:GetService("Lighting"):WaitForChild("ColorCorrection") --Path to your ColorCorrectionEffect.

transitions.FadeOut(colorCorrectionObject) --To fade out
--Or,
transitions.FadeIn(colorCorrectionObject) --To fade in
Option 2: Tween the Brightness
local transitions= {}

local TweenService = game:GetService("TweenService") --Define the tween service.

transitions.FadeOut = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {Brightness = -1} --Our property goal 
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

transitions.FadeIn = function(object) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1)  --Tween settings
	local goal = {Brightness = 0} --Our property goal 
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end

--How to use:
local colorCorrectionObject = game:GetService("Lighting"):WaitForChild("FadeInOut") --Path to your ColorCorrectionEffect.

transitions.FadeOut(colorCorrectionObject) --To fade out
--Or,
transitions.FadeIn(colorCorrectionObject) --To fade in
Option 3: Tween both TintColor and Brightness:
local TweenService = game:GetService("TweenService") --Define the tween service.

local function fade(object, bright, color) --New function added to the table
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 1) --Tween settings
	local goal = {Brightness = bright; TintColor = color } --Our property goal
	local tween = TweenService:Create(object, info, goal) --Create the tween
	tween:Play() --Play the tween
	return tween --Return it, so we can wait to see if it's completed.
end
--How to use:
local colorCorrectionObject = game:GetService("Lighting"):WaitForChild("FadeInOut") --Path to your ColorCorrectionEffect.
fade(colorCorrectionObject, 3, Color3.fromRGB(255,0,0)) --Change the values accordingly, this code will create a Red Bright Fade-out.

For Instance:

local transitions = require(game:GetService("ReplicatedStorage"):WaitForChild("Transitions")) --Load the transition functions.
local colorCorrectionObject = game:GetService("Lighting"):WaitForChild("FadeInOut") --Path to your ColorCorrectionEffect.
-----Option 1 & 2:
transitions.FadeOut(colorCorrectionObject) --To fade out
--Or,
transitions.FadeIn(colorCorrectionObject) --To fade in
-----Option 3:
transitions(colorCorrectionObject, 3, Color3.fromRGB(255,0,0)) --Red bright fade-out, change the values accordingly for different result.

Use Cases:

There are many use cases to transitions, here are a few example:

  1. Death Screen
  2. Loading Screen
  3. Teleportation screen
  4. Flashbacks
  5. Intros & Outros.

And many more! Creativity is the key.

Here are a few code examples:

1. Fade out on Part touch

Local Script:

local debounce = false
local module = require(game:GetService("ReplicatedStorage").Transitions) --Get the function table
local part = workspace:WaitForChild("FadeInOutPart") --Path to your part.
part.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit:FindFirstAncestorOfClass("Model"))
	if(debounce == false and player == game:GetService("Players").LocalPlayer) then --If debounce is false and the touch is a player then
		debounce = true
		local tween1 = module.FadeOut(game:GetService("Lighting").FadeInOut) --Run the Fade-Out function that returns the tween
	
		tween1.Completed:Wait() --Wait until the tween is completed
		
		wait(1) -- Wait before tweening back
		
		
		local tween2 = module.FadeIn(game:GetService("Lighting").FadeInOut)  --Run the Fade-Out function that returns the tween
		
		tween2.Completed:Wait() --Wait until the tween is completed
		
		print("Done fading")
		wait(0.5)
		debounce = false
	end
	
end)
2. Fade out on Death

Local script in StarterPlayerScripts:

local plr = game:GetService("Players").LocalPlayer --Get the player
local transitions = require(game:GetService("ReplicatedStorage"):WaitForChild("Transitions")) --Load the transition functions.
local colorCorrectionObject = game:GetService("Lighting"):WaitForChild("FadeInOut") --Path to your ColorCorrectionEffect.

plr.CharacterAdded:Connect(function(char) --When character is spawned
	wait(1) --Short wait before fade in.
	transitions.FadeIn(colorCorrectionObject) --Fade in
	local hum = char:WaitForChild("Humanoid") --Wait until the humanoid exists.
	hum.Died:Connect(function() --When the player dies
		transitions.FadeOut(colorCorrectionObject) --Fade out
	end)
end)

--Note: You don't have to worry about the humanoid function being stored in memory since connections are disconnected when something is destroyed.

You can use the function from the server as well to make transitions for all of the players. Or use a remote event and :FireAllClients()


Edit History:

  1. Edit 6/27/20: Removed Poll, please provide only Constructive criticism/feedback, not just bad votes.

  2. Edit 5/16/21: Added some better formatting and wording

  3. Edit 5/16/21: Renewed the videos and added more code examples.


If you have any feedback or suggestions, or anything to correct, please let me know :slightly_smiling_face:. Constructive Feedback is highly appreciated.

44 Likes

Very nice and detailed thread.

Although, fading via this method has one caveat, as shown in the first gif, the name of any named Humanoid objects will show on your screen even after you’ve faded.

In the gif, you can see that the word “Dummy” still appears, even though the screen was turning black. I’m not 100% sure if this is the case with BillboardGuis as well.

By using a Frame that fills up the entire screen, this doesn’t happen as the 2D UI element obstructs any billboard GUIs.

4 Likes

Thanks for the feedback :+1: :slight_smile: .
You’re right, I’ll see what I can do. I added the video to demonstrate the con.

Edit:
The solution for that may be more complicated.
Thanks for letting me know, I’ve noted the Pros/Cons in the guide.

1 Like

Interesting topic,
Why did you use a module script for 3 functions ?

3 Likes

Thanks, There are only 2 or 1 functions in the module. Just different ways to accomplish Fade In/out transitions.

Edit:

I used a module script so I can easily access it from the client and the server without having to repeat myself (copy the functions each time I want to use this).

I’ve noted the reason in the guide, and provided the functions without the module too

2 Likes

Oh alright, this explains everything :slight_smile:

2 Likes