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

I'm trying to make a custom loading screen with TeleportService, but nothing happens?

Asked by 5 years ago
Edited 5 years ago

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.

0
Players.NumPlayers is deprecated, do not use it. connect is also deprecated, so don't use that either. User#19524 175 — 5y
0
loadingguiscript is defined but not initialized with a reference/value and you didnt put any customloadingscreen as an argument radusavin366 617 — 5y

Answer this question