Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Custom Teleport UI not working?

I'm making a custom teleport screen where the screen fades to black instead of using the default place teleporting screen. I have the code in a normal script. However, when I touch it, it uses the default teleporting screen instead of the custom one.

local LoadingScreen

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        game:GetService("TeleportService"):Teleport(270180843, player)
for i = 1, 0, -.05 do
		LoadingScreen.BackgroundTransparency = i
		wait()
	end
	-- Disable default teleport gui
game:GetService("TeleportService").CustomizedTeleportUI = true
 
-- Bind function to teleport button that request's server teleport the player
	-- Make loading screen visible
	LoadingScreen.Visible = true
 
	-- Remove all of the core gui elements
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
 
	-- Fade screen in
	for i = 1, 0, -.05 do
		LoadingScreen.BackgroundTransparency = i
		wait()
	end
	LoadingScreen.BackgroundTransparency = 0
end
end
script.Parent.Touched:connect(onTouched)

1 answer

Place line 12 outside the function, or right before teleporting players.

local LoadingScreen

-- You can place it here
game:GetService("TeleportService").CustomizedTeleportUI = true

function onTouched(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
		-- Or you can place it here
		game:GetService("TeleportService"):Teleport(270180843, player)
		for i = 1, 0, -.05 do
			LoadingScreen.BackgroundTransparency = i
			wait()
		end
		
		LoadingScreen.Visible = true
		
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
		
		for i = 1, 0, -.05 do
			LoadingScreen.BackgroundTransparency = i
			wait()
		end
		LoadingScreen.BackgroundTransparency = 0
	end
end

script.Parent.Touched:connect(onTouched)

This discussion is preserved as it was. New answers, comments, and votes are closed.