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)
