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)