My loading screens just won't work

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want my game to have a Vesteria-like loading screen. I love the way they have no default loading screen, but last time I posted about this, I was told that using :SetTeleportGui and :GetArrivingTeleportGui, but I tried and it just would not work. I was getting frustrated and thought, let’s ask again.

  2. What is the issue?
    My loading screen will show when leaving, but in between leaving Place1 and joining Place2, it still shows the default one.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve posted before and gotten a false answer (didn’t work for me for some reason) and, here’s my code.

Found in a LocalScript in Place1’s StarterGui. [P.S. the event is in another script dedicated completely to firing that event.]

	print("received event")
	local player = game.Players.LocalPlayer
	if map == 1 then
		print("identified map")
		script.Parent.Visible = true
		wait(3)
		local TPService = game:GetService("TeleportService")
		script.Parent.Parent.AmazonRainforest.Loading.Enabled = true
		game.ReplicatedFirst:RemoveDefaultLoadingScreen()
		TPService:TeleportToPrivateServer(3345365809, rServer, player.Money.Value, script.Parent.Parent.AmazonRainforest.Loading)
	end
end)```

**Receiving the Loading Screen - Place2 ReplicatedFirst:**
```local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

local customLoadingScreen = TeleportService:GetArrivingTeleportGui()
if customLoadingScreen then
	local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
	ReplicatedFirst:RemoveDefaultLoadingScreen()
	customLoadingScreen.Parent = playerGui
	customLoadingScreen.TextLabel.Text = "Loading Assets..."
	repeat wait(1) until game:IsLoaded()
	customLoadingScreen.TextLabel.Text = "Waiting for players.  Currently at " .. #game.Players:GetPlayers() .. " / " .. game.ReplicatedStorage.NeededPlayers.Value
	repeat wait(3) until #game.Players:GetPlayers()
	customLoadingScreen:Destroy()
end

If you need to know, @colbert2677 answered. (No bad words about you; a great guy! Just couldn’t get the solution to work.)

Thanks! Any help is appreciated!

Two chief issues here: you are calling TeleportToPrivateServer on the wrong environment (LocalScript on the client) and that you’re passing incorrect arguments to TeleportToPrivateServer. Your GetArrivingTeleportGui code segment doesn’t have any immediate issues.

First things first is to address this. LocalScripts are not allowed to use TeleportToPrivateServer for security and UX reasons. You may want to review the documentation page for the function. Considering that you do teleport, what I assume this is doing is performing a regular teleport instead of throwing an error stating that the function is only available on the server.

After you change what script is calling the function, you need to address the arguments that you are sending. Your first two arguments are fine, the other two can be dropped. The money value should not be sent over as TeleportData because that’ll be the TeleportData that all players involved in the teleport will use. Only use it if you’re teleporting a single user over. As for the TeleportGui, that can be handled via SetTeleportGui over the TeleportGui argument.

When assembled, your code should look something like this:

TPService:SetTeleportGui(script.Parent.Parent.AmazonRainforest.Loading)
TPService:TeleportToPrivateServer(3345365809, rServer, playerList)

Where playerList is a table of players that are meant to join the server. If you are only teleporting one player, make them the only entry of the table. If there are multiple, just place more players. For teleporting the whole server, you can just pass GetPlayers (after calling it) from the Players service as it returns a table.

2 Likes

Hey, colbert!

Thanks for coming and restating what you meant earlier; I’m no longer confused. It worked.

You’ve gained yourself another Solution, good sir! Thanks again! :slight_smile:

1 Like

Hey, just make sure to mark the response as a solution so that people know that your problem is now solved. When people are having a similar problem they’ll search for it, but are more likely to skip past it if it’s not clear that it has been solved. It’ll also reduce the likelihood of further replies in attempt to solve the problem.

I am officially forgetful! Thanks for the reminder. :slight_smile: