Hi,
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
ShowBlackScreen:FireClient(plr)
TS:TeleportToPrivateServer(3410032453,code,{plr}, nil, nil, BlackScreen)
end
end
local script (in replicated first) on lobby:
local RS = game:GetService("ReplicatedStorage")
local ShowBlackScreen = RS:WaitForChild("ShowBlackScreen")
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(1)
local screen = Instance.new("ScreenGui")
screen.Name = "BlackScreen"
screen.Parent = PlayerGui
local frame = Instance.new("Frame")
frame.Size = UDim2.new(1,0,1,0)
frame.Parent = screen
frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
frame.BorderSizePixel = 0
frame.BackgroundTransparency = 1
frame.Visible = false
ShowBlackScreen.OnClientEvent:Connect(function()
frame.Visible = true
for i = 50, 0, -1 do
frame.BackgroundTransparency = i/50
wait()
end
frame.BackgroundTransparency = 0
end)
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")
PlayerGui:SetTopbarTransparency(1)
local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
if customLoadingScreen then
local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
ReplicatedFirst:RemoveDefaultLoadingScreen()
customLoadingScreen.Parent = playerGui
-- animate screen here
for i = 0, 50, 1 do
customLoadingScreen.BackgroundTransparency = i/50
wait()
end
PlayerGui:SetTopbarTransparency(0)
-- destroy screen
customLoadingScreen:Destroy()
end
OutPut says that its infinite yield possible of RS:WaitForChild(“ShowBlackScreen”)
Thanks for answering !