I want to make a game where it teleports everybody in the server to the game place. I got that done with ReserveServe, but it's the CustomLoadingScreen that isn't working. Can anybody help?

Initialize teleport script:

while true do
print("success")
wait()
repeat
wait()
until game.Players.NumPlayers >= 1

wait(25)

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)
 
local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui
 
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0,100000,0,100000)
frame.FontSize = Enum.FontSizeSize18
frame.BackgroundColor3 = Color3.new(0,0,0)
frame.Parent = screen
 
spawn(function()
	for i = 50, 0, -1 do
		frame.BackgroundTransparency = i/50
		wait()
	end
end)
 
local TeleportService = game:GetService("TeleportService")
local destinationPlaceId = 2163624217

local reservationCode = TeleportService:ReserveServer(destinationPlaceId)

local players = game:GetService("Players"):GetPlayers()

TeleportService:TeleportToPrivateServer(destinationPlaceId, reservationCode, players)

end

Receive teleport script:

game:GetService("TeleportService").LocalPlayerArrivedFromTeleport:connect(function(customLoadingScreen, data)
	spawn(function() 
		
		local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
		PlayerGui:SetTopbarTransparency(0) 
	end)
	local loadingGuiScript 
	loadingGuiScript.Disabled = false
	loadingGuiScript.Parent = customLoadingScreen
	wait(5) 
	customLoadingScreen:Destroy()
end)

I used most of it from the wiki page.

2 comments

0

Players.NumPlayers is deprecated, do not use it. connect is also deprecated, so don't use that either.

0

loadingguiscript is defined but not initialized with a reference/value and you didnt put any customloadingscreen as an argument