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
5 years ago
Edited 5 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:

1local function moveto_mainGame(plr)
2        if plr:FindFirstChild("Settings").Playing.Value == true then
3    local RS = game:GetService("ReplicatedStorage")
4    local ShowBlackScreen = RS:WaitForChild("ShowBlackScreen")
5    local BlackScreen = game.StarterGui.BlackScreen
6    ShowBlackScreen:FireClient(plr)
7           TS:TeleportToPrivateServer(3410032453,code,{plr}, nil, nil, BlackScreen)
8        end
9    end

local script (in replicated first) on lobby:

01local RS = game:GetService("ReplicatedStorage")
02local ShowBlackScreen = RS:WaitForChild("ShowBlackScreen")
03local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
04PlayerGui:SetTopbarTransparency(1)
05 
06local screen = Instance.new("ScreenGui")
07screen.Name = "BlackScreen"
08screen.Parent = PlayerGui
09 
10local frame = Instance.new("Frame")
11frame.Size = UDim2.new(1,0,1,0)
12frame.Parent = screen
13frame.BackgroundColor3 = Color3.fromRGB(0,0,0)
14frame.BorderSizePixel = 0
15frame.BackgroundTransparency = 1
View all 25 lines...

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

01local TeleportService = game:GetService("TeleportService")
02local Players = game:GetService("Players")
03local ReplicatedFirst = game:GetService("ReplicatedFirst")
04local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
05PlayerGui:SetTopbarTransparency(1)
06 
07local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
08if customLoadingScreen then
09    local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
10    ReplicatedFirst:RemoveDefaultLoadingScreen()
11    customLoadingScreen.Parent = playerGui
12    -- animate screen here
13   for i = 0, 50, 1 do
14        customLoadingScreen.BackgroundTransparency = i/50
15        wait()
16end
17PlayerGui:SetTopbarTransparency(0)
18    -- destroy screen
19    customLoadingScreen:Destroy()
20end

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 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 — 5y
0
EDIT: Now only the teleportation work but not the custom screen mist0s 38 — 5y
0
Can you put the script that you used and which work and your post please ? mist0s 38 — 5y
0
on* mist0s 38 — 5y
0
Ok so the script work but not totally. From where the player is teleported doesn't work. mist0s 38 — 5y
Ad

Answer this question