Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Make a custom loading screen ?

Asked by
mist0s 38
4 years ago
Edited 4 years ago

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

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I found the problem. The Black Screen Gui is made on the client, so the server cannot send it through TeleportService:TeleportToPrivateServer() as it cannot see the gui. I still am testing if the other part of the code can work, so please wait, but the best way to fix that is to make it pre-runtime in the StarterGui, that way the server can see it too.

EDIT: Actually, keep all of the client side scripting (don't listen to my suggestion) the same, but instead of putting the pre-made gui in StarterGui, put it in ReplicatedStorage so you wont have a useless ScreenGui in each Player's PlayerGui. Then, change the reference to the black screen from StarterGui to ReplicatedStorage, which you already have a variable for. Do this on the ServerScript in the lobby. Also, on the LocalScript in the the not-lobby make it say customLoadingScreen.Frame.BackgroundTransparency, not customLoadingScreen.BackgroundTransparency.

EDIT 2: After doing what you did plus my changes, the system works perfectly!

0
I do your changes but now it say that BlackScreen is not a valid member of ReplicatedStorage, you know why ? (and thanks for the answer) mist0s 38 — 4y
0
EDIT: Now only the teleportation work but not the custom screen mist0s 38 — 4y
0
Can you put the script that you used and which work and your post please ? mist0s 38 — 4y
0
on* mist0s 38 — 4y
0
Ok so the script work but not totally. From where the player is teleported doesn't work. mist0s 38 — 4y
Ad

Answer this question