How do I fade screen to black?

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
screenGui.Parent = playerGui
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(16, 16, 16)
textLabel.Font = Enum.Font.Merriweather
textLabel.TextColor3 = Color3.new(0.819608, 0.819608, 0.819608)
textLabel.Text = ""
textLabel.TextSize = 40
textLabel.Parent = screenGui
local TextTurnOnSound = game.SoundService:WaitForChild("eh")

-- Remove the default loading screen
ReplicatedFirst:RemoveDefaultLoadingScreen()

wait(5)  -- Force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end
local BlackScreenFade = Instance.new("Frame")
BlackScreenFade.BackgroundColor3 = Color3.new(16, 16, 16)
local Transperancy = {}
BlackScreenFade.BackgroundTransparency = 1
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local tween = TweenService:Create(BlackScreenFade, tweenInfo, Transperancy)
BlackScreenFade.Size = UDim2.new(1, 0, 1, 0)

if game:IsLoaded() then
	textLabel.Text = "Extraction Point"
	if TextTurnOnSound.Playing then
		TextTurnOnSound.Playing = false
	else
		TextTurnOnSound.Playing = true
	end
	wait(2)
	tween:Play()
end

Nope, 0 errors, output clean. It just - simply doesn’t work, with no red lines underneath any text on my code, nor any errors!

Ok on your
local tween = TweenService:Create(BlackScreenFade, tweenInfo, Transperancy)
line, change that to
local tween = TweenService:Create(BlackScreenFade, tweenInfo, {BackgroundTransparency = 0})

Did that - still doesn’t work… sigh

You forgot the initial Parent of the new frame.
after this line

BlackScreenFade.BackgroundTransparency = 1

The following line to parent it to the screenGui

BlackScreenFade.Parent = screenGui
local TS = game:GetService("TweenService")
local frame = -- Your frame.
local goal = {BackgroundTransparency = 0}
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Quad)
local Tween = TS:Create(frame,tweenInfo,goal)

Tween:Play()
1 Like

Thanks. It tween now - but instead of transperancy - it turns white

Also, try this.

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
screenGui.Parent = playerGui
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(16, 16, 16)
textLabel.Font = Enum.Font.Merriweather
textLabel.TextColor3 = Color3.new(0.819608, 0.819608, 0.819608)
textLabel.Text = ""
textLabel.TextSize = 40
textLabel.Parent = screenGui
local TextTurnOnSound = game.SoundService:WaitForChild("eh")

-- Remove the default loading screen
ReplicatedFirst:RemoveDefaultLoadingScreen()

wait(5)  -- Force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end

local BlackScreenFade = Instance.new("Frame")
BlackScreenFade.BackgroundColor3 = Color3.new(16, 16, 16)
BlackScreenFade.BackgroundTransparency = 1
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
local tween = TweenService:Create(BlackScreenFade, tweenInfo, {BackgroundTransparency = 0)
BlackScreenFade.Size = UDim2.new(1, 0, 1, 0)

if game:IsLoaded() then
	textLabel.Text = "Extraction Point"
	if TextTurnOnSound.Playing then
		TextTurnOnSound.Playing = false
	else
		TextTurnOnSound.Playing = true
	end
	wait(2)
	tween:Play()
end

Here Color3.new() isn’t correct. You would want to use Color3.fromRGB() to get the proper color with RGB numbers.

And no problem, remember to mark the correct answers so others would know.

it fades the text - not the background right now, I want it to fade the background.

We do not run the Tween on the text.
I guess the frame maybe over top of the text. Then you would want to set the ZIndex of the text to a higher number.

i.e.

textLabel.ZIndex = 2


Here is a full view of what happened

while objectTransparency <= 1 do
   wait(.05)
   objectTransparency = objectTransparency - .05
end

I added a TimeToTween variable, and made it half a second. Just make it however long you want.

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local TweenService = game:GetService("TweenService")

local TimeToTween = 0.5

local Info = TweenInfo.new(TimeToTween, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false)

local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
screenGui.Parent = playerGui
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(16, 16, 16)
textLabel.Font = Enum.Font.Merriweather
textLabel.TextColor3 = Color3.new(0.819608, 0.819608, 0.819608)
textLabel.Text = ""
textLabel.TextSize = 40
textLabel.Parent = screenGui

textLabel.TextTransparency
-- Remove the default loading screen
ReplicatedFirst:RemoveDefaultLoadingScreen()

task.wait(5)  -- Force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end

if game:IsLoaded() then
	textLabel.Text = "Extraction Point"
	task.wait(2)
	screenGui:Destroy()
	local Tween = TweenService:Create(textLabel, Info, {BackgroundTransparency = 1, TextTransparency = 1})
	Tween:Play()
end

Anyways, I hope this helps!

Alright, came back to add-on additional details and build upon what we’ve created.
The current solution does not match the topic, as it just destroys the created UI.

This below gets rid of the unnecessary top black frame and just uses the text label’s properties.

Here are the events that happen:

  • Create the needed frame
  • Remove the default loading screen. (Limits to 5 seconds in special cases)
  • Wait a minimum amount, then wait for the game to load, if not already loaded
  • Display the Experience name, then fade the text out to just showing a black screen again.
  • Then fade the background out to then show the game
  • Necessary cleaning
-- Services
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local TweenService = game:GetService("TweenService")

-- TweenInfo
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false)

-- Values
local player = Players.LocalPlayer 
local playerGui = player:WaitForChild("PlayerGui")

-- Build Gui
local screenGui = Instance.new("ScreenGui", playerGui)
screenGui.IgnoreGuiInset = true

-- Build Gui TextLabel
local textLabel = Instance.new("TextLabel", screenGui)
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(16, 16, 16)
textLabel.Font = Enum.Font.Merriweather
textLabel.TextColor3 = Color3.fromRGB(209, 209, 209)
textLabel.Text = ""
textLabel.TextSize = 40

-- Remove the default gui to display ours
ReplicatedFirst:RemoveDefaultLoadingScreen()

task.wait(5)  -- Force screen to appear for a minimum number of seconds
if not game:IsLoaded() then game.Loaded:Wait() end -- Wait until the game is loaded. (Another alternative is to count the assets left.)


textLabel.Text = "Extraction Point" -- Sets the text to appear
task.wait(3) -- Time until text fades out
TweenService:Create(textLabel, tweenInfo, { TextTransparency = 1 }):Play() -- Tweens TextTransparency to 1
task.wait(2) -- Time until background fades out
TweenService:Create(textLabel, tweenInfo, { BackgroundTransparency = 1 }):Play() -- Tweens BackgroundTransparency to 1
task.wait(tweenInfo.Time) -- Wait the time for the last tween to complete
screenGui:Destroy() -- Clean up the gui after use.
1 Like