Problem With Teleporting Loading Screen

Hi im currently working on my game “Galatic Mayhem” and ive encountered a Problem,
So when the players teleport to the other game i want there to be a loading screen. What ive done, is a event the call the client to set the loading screen so just. Teleport Service:SetTeleportGUI(guiName) and then in the other game in a script in replicated first ive done this for the loading screen

    local playerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
    local ReplicatedFirst = game:GetService("ReplicatedFirst")
     
    local LoadingScreen = TeleportService:GetArrivingTeleportGui()
    if LoadingScreen then
  
        ReplicatedFirst:RemoveDefaultLoadingScreen()
        LoadingScreen.Parent = playerGui

        wait(5)
else

end

         
        LoadingScreen:Destroy()
    



But what ive seen (with using print ) is that the loading screen is nil, im not sure why, this is my Script that set the loading GUI (Localscript)

local gui = game.ReplicatedStorage.LoadingScreen:Clone()
local tele = game:GetService("TeleportService")
game.ReplicatedStorage.LoadingScreenEvent.OnClientEvent:Connect(function()
	local code = tele:ReserveServer(5020544104)
	gui.Parent = game.Players.LocalPlayer.PlayerGui
    tele:SetTeleportGui(gui)
	tele:TeleportToPrivateServer(game.PlaceId,code,,game.Players.LocalPlayer,nil,gui)
	print("Teleported")
	
	
				
		end)
		
		
		
	
end)

Thank You

 

u can’t use TeleportToPrivateServer() in a LocalScript

Oh, but the teleport is still working.

Are you sure its a localscript?

how would i make a loading screen for teleport then?

and yes i am sure it is a local script

u would teleort on the server and set the gui on the client
https://developer.roblox.com/en-us/api-reference/function/TeleportService/TeleportToPrivateServer

it also expects a table of players

ok thanks, my bad i actually teleported on the server as well

remove the teleportation stuff. and it should work. also, u should wait a second after firing the remote

1 Like

Thanks for your help. 30 chars

The loading screen is still nil.

Well when i get arriving teleport Gui, its telling me its nil

This article on devhub may help

https://developer.roblox.com/en-us/articles/Custom-Loading-Screens

Is the code in a local script located in replicated first?

Yes. 30 charrssssssssssssssssss