PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Creating Custom Teleport GUI Code Sample 2

Creating Custom Teleport GUI Code Sample 2

Oct 01 2018, 3:10 AM PST

-- Local script in other place

-- Declare local variables for Roblox Services
local TeleportService = game:GetService('TeleportService')
local UserInputService = game:GetService('UserInputService')
local StarterGui = game.StarterGui

-- Hide Core GUI and mouse
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)	
UserInputService.MouseIconEnabled = false	

-- Bind function to teleport arrival
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(loadingGui, data)
	-- Pause briefly to allow level to load	
	wait(2)	
	
	-- Fade out loading screen
	for i = 0, 1, .05 do
		loadingGui.loadingScreenFrame.BackgroundTransparency = i
		wait()
	end
	loadingGui.loadingScreenFrame.BackgroundTransparency = 1
	
	-- Show Core GUI and mouse
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	UserInputService.MouseIconEnabled = true	
end)