Using a Custom Loading Screen for a Reserved Server

Hello! I’m trying to find a way to use a custom loading screen for when a player/s have been teleported into a reserved server. Sadly, I do not know where in these scripts to do that, so I both scripts here, one local, and I need to find where to put the code since I already have a loading screen and know how to put one in.

Thanks for any help!

Code:

--StarterGui.Script
local Players = game:GetService("Players") -- looking for the players

local reserve = script.Parent.ScreenGui.PlayFrame.GameTypeButton1 -- the button that we have to press to do this
--local MainMusic = game.SoundService["Distorted Reality Perception - Leon Riskin"] -- just for music
--local AmbienceMusic = game.Workspace.Sounds["Afterworld Ambience Weird Rumbling Ambience  (SFX)"] --music that will play

local player = script:FindFirstAncestorOfClass("Player") -- finding our player
local debounce = false -- there is no current throttle

reserve.MouseButton1Click:Connect(function()
	print("starting reserve")
	if debounce then return end -- if there is already a debounce, we cant do the rest of the lines until its over.
	debounce = true -- so the player wont throttle it and spam it, making it crash or mess up the teleport

	local ts = game:GetService("TeleportService") --defining teleport service
	local access = ts:ReserveServer(game.PlaceId) -- game.PlaceId = our place id and where we are teleporting
	task.wait(5)
	ts:TeleportToPrivateServer(game.PlaceId, access, Players:GetPlayers()) -- getting the players and place that we are teleporting to
	warn("Teleporting everybody...") -- warning us that we are teleporting

	task.wait(5)
	debounce = false -- in case it didnt work before, the debounce is now off so we can try to teleport again.
end)

local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0 -- i forget about this too

if isReserved == true then -- so once we "reserve" the server, we do all this stuff
	game.ReplicatedStorage.RemoteEvent:FireClient(player) 
	print("Reserved is true: ServerClient is firing to FireClient")
end
--StarterGui.Script.LocalScript (Yes, this is inside the previous script. idk why can did that)
local Players = game:GetService("Players")

local ScreenGui = Players.LocalPlayer.PlayerGui.ScreenGui
local MenuMusic = game.SoundService["Distorted Reality Perception - Leon Riskin"]
local AmbienceMusic = workspace.Sounds["Afterworld Ambience Weird Rumbling Ambience  (SFX)"]
local Camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local Char = player.Character or player.CharacterAdded:Wait()
local Humanoid = Char:WaitForChild("Humanoid")

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function() 
	print("reserved is true for ClientSide")
	ScreenGui.Enabled = false
	repeat 
        wait()
		Camera.CameraType = Enum.CameraType.Custom
	until Camera.CameraType == Enum.CameraType.Custom
	Camera.CameraSubject = Humanoid
	MenuMusic.Playing = false
	AmbienceMusic.Playing = true
	game.SoundService.AmbientReverb = "Arena"
end)
1 Like

Hello there. Can you try tweaking this code to make it work for your situation? The script should go into ReplicatedFirst.

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

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

-- Create a basic loading screen
local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true

local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(0, 20, 40)
textLabel.Font = Enum.Font.GothamMedium
textLabel.TextColor3 = Color3.new(0.8, 0.8, 0.8)
textLabel.Text = "Loading"
textLabel.TextSize = 28
textLabel.Parent = screenGui

-- Parent entire screen GUI to player GUI
screenGui.Parent = playerGui

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

--wait(3)  -- Optionally force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
	game.Loaded:Wait()
end
screenGui:Destroy()

Isn’t this just the code from the dev hub? Sorry, this doesn’t really help me, I’m asking how to use a custom loading screen for a reserved server, not how to make one.

I don’t understand what you mean. Can you elaborate/explain a bit more?

Try using TeleportService:SetTeleportGui()

Trying this, it appears to work! But, I also want to know if I should make a localscript in ReplicatedFirst and use TeleportService:GetArrivingTeleportGui() to make it transition out?
Maybe something like this:

local TeleService = game:GetService("TeleportService")

local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0
if isReserved then
	local LoadingGui = TeleService:GetArrivingTeleportGui()
	game:GetService("TweenService"):Create(LoadingGui.LoadingFrame,TweenInfo.new(.5),{BackgroundTransparency = 1}):Play()
	game:GetService("TweenService"):Create(LoadingGui.LoadingFrame.Text,TweenInfo.new(.5),{TextTransparency = 1}):Play()
end

also hello miner’s haven dev :o

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.