Custom loading screen between places

So I have two places, when it teleport to the private server, I want to make a black screen who start transparency and became more and more black (with background transparency) (for the players who will be teleported) and between the private place teleport the custom loading screen is black and when the player is to the place, the screen is black and become less and less black.

So here is the code:

script on lobby:

local function moveto_mainGame(plr)
        if plr:FindFirstChild("Settings").Playing.Value == true then
	local RS = game:GetService("ReplicatedStorage")
	local ShowBlackScreen = RS:WaitForChild("ShowBlackScreen")
	local BlackScreen = game.StarterGui.BlackScreen
           TS:TeleportToPrivateServer(3410032453,code,{plr}, nil, nil, BlackScreen)

local script (in replicated first) on lobby:

local RS = game:GetService("ReplicatedStorage")
local ShowBlackScreen = RS:WaitForChild("ShowBlackScreen")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

local screen ="ScreenGui")
screen.Name = "BlackScreen"
screen.Parent = PlayerGui

local frame ="Frame")
frame.Size =,0,1,0)
frame.Parent = screen
frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
frame.BorderSizePixel = 0
frame.BackgroundTransparency = 1
frame.Visible = false

	frame.Visible = true
	for i = 50, 0, -1 do
		frame.BackgroundTransparency = i/50
	frame.BackgroundTransparency = 0

and local script in the game (in replicated first):

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
if customLoadingScreen then
    local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
    customLoadingScreen.Parent = playerGui
    -- animate screen here
   for i = 0, 50, 1 do
		customLoadingScreen.BackgroundTransparency = i/50
    -- destroy screen

OutPut says that its infinite yield possible of RS:WaitForChild(“ShowBlackScreen”)

Thanks for answering :smiley: !

1 Like

Scripts inside GUIs that are provided as a loading GUI with TeleportService are static and do not automatically animate, your best shot is having the animation script inside the game that receives the player and cloning it into the GUI when they arrive, you should read this article (at the bottom) for more on that,

I already rode this article but it doesn’t help me… but thanks for answer !! :smiley:

I’m assuming from your post that your script isn’t working. What I’m saying is that scripts inside GUIs which are used as loading screens do not work. That script needs to be put in the game that receives the player and then put into the GUI after to animate it.

But the problem is that for now, the script doesn’t do anything in the lobby and because of this it doesn’t teleport the player.

Assuming the teleport takes a while, yes, you could fade in a black screen. However due to you setting up the UI on the server there can be a network latency and result in an outdated UI, which is not black yet.


Since you’re using the previous UI, for a better user experience you may keep an UI in the other place too and always run the animation even if no UI was provided.

For the animation I didn’t need TweenService, it’s only the background transparency which is changing. But for the lobby local script, it says “ReplicatedFirst.LocalScript:21: attempt to index a nil value” which is this line “ShowBlackScreen.OnClientEvent:Connect(function()”