I’ve tried looking all over the wiki posts about custom loading screens and they don’t really make sense to me when I tried to use all these methods. So please don’t just reply with a link to the wiki posts.
So I’m just trying to make a custom loading GUI when you’re teleporting to a different game in the same universe via TeleportService. So when you walk through a door, a GUI prompt will pop up ensuring that you want to teleport there, as seen in the explorer here:
With the actual code in that Teleport LocalScript being this:
script.Parent.MouseButton1Click:Connect(function()
script.click:Play()
local player = game.Players.LocalPlayer
if player then
script.Parent.Visible=false
script.Parent.Parent.no.Visible=false
script.Parent.Parent.Visible=false
script.Parent.Parent.Parent.Visible=false
wait()
script.loadingGui.shop.strings.Disabled = false
script.loadingGui.shop.script.Disabled = false
script.loadingGui.shop.fade.Disabled = false
game:GetService("TeleportService").CustomizedTeleportUI = true
game:GetService("TeleportService"):Teleport(2341927225,player,nil,script.loadingGui)
end
end)
script.Parent.MouseEnter:Connect(function(click)
script.over:Play()
end)
So that’s all in the Workspace on the starting place, but here’s the LocalScript that’s in the ReplicatedFirst on the receiving game that you will get teleported in:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(customLoadingScreen, data)
spawn(function()
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)
end)
local ui = script.loadingGui:Clone()
ui.Parent = customLoadingScreen
wait(5)
customLoadingScreen:Destroy()
end)
Right now, when you click Yes in the starting place, the loading GUI does pop up, my only issue is that once you actually teleport to that place I see no GUI and I just see the map loading in and me spawning.
After taking a peek at the api reference you can spot some things you are not doing correctly / not doing at all.
First off all, remember to remove the default loading screen:
ReplicatedFirst:RemoveDefaultLoadingScreen()
Secondly, assign the customLoadingScreen to PlayerGui or else it wont show up.
Last off, you should delete that last thing where you set somethings parent to customLoadingScreen since you shouldn’t need it anymore:
local ui = script.loadingGui:Clone() ui.Parent = customLoadingScreen
The finished code should now look something like this:
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(customLoadingScreen, data)
spawn(function()
local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
--Out of interest, what is this actually supposed to do?
PlayerGui:SetTopbarTransparency(0)
end)
customLoadingScreen.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
--Remember that you have to wait until the PlayerGui loads.
ReplicatedFirst:RemoveDefaultLoadingScreen()
wait(5)
customLoadingScreen:Destroy()
end)
This didn’t work for me, I have no clue what’s wrong, I tried printing everything and it goes through all the parts of the script, I just don’t see any GUI when I teleport in-game.
11 months later for code that’s probably even older.
CustomizedTeleportUI was deprecated (and removed) as custom teleport UIs will automatically show if passed as an argument in a teleport function or set by SetTeleportGui. Calling RemoveDefaultLoadingScreen outside of ReplicatedFirst is pointless because the loading screen will have disappeared by the time this code executes.
You should also maintain convention consistency. You use GetService for TeleportService but not for ReplicatedFirst; and you write out GetService for TeleportService reice when you can just hold it in a variable and use that to avoid redundancy.