game.ReplicatedStorage.DoFancyTeleport.OnClientEvent:Connect(function(J,M)if script.Parent:FindFirstAncestorOfClass("\087\111\114\107\115\112\097\099\101")then return end if M==nil then M=true end local o=game.Players.LocalPlayer.Character if not o then return end local G=o:FindFirstChild("\085\112\112\101\114\084\111\114\115\111")if not G then G=o:FindFirstChild("\084\111\114\115\111")end if not G then return end if db then return end db=true if M then script.Parent.Visible=true script.Parent.BackgroundTransparency=1 local J={BackgroundTransparency=0}local M=TweenService:Create(script.Parent,info,J)M:Play()wait(FadeTime)end if G then local A=o:FindFirstChild("\072\117\109\097\110\111\105\100")if A then A.Sit=false end if typeof(J)=="\086\101\099\116\111\114\051"then G.CFrame=(G.CFrame-G.CFrame.p)+J elseif typeof(J)=="\073\110\115\116\097\110\099\101"then if J:IsA("\066\097\115\101\080\097\114\116")then G.CFrame=J.CFrame+Vector3.new(0,J.Size.Y/2+3,0)workspace.CurrentCamera.Focus=G.CFrame workspace.CurrentCamera.CFrame=G.CFrame*CFrame.new(0,5,-10)end end if M then wait(BlackoutTime)end end if M then local J={BackgroundTransparency=1}local M=TweenService:Create(script.Parent,info,J)M:Play()wait(FadeTime)script.Parent.Visible=false end wait(DelayTime)db=false end)
--[[
	destination: The Part to be teleported to.
	fade: Whether to use the fade effect. (Defaults to true if not specified)
--]]

game.ReplicatedStorage.DoFancyTeleport.OnClientEvent:Connect(function(destination, fade)
	if script.Parent:FindFirstAncestorOfClass("Workspace") then
		return
	end --Just in case studio test runs LocalScripts in places where it's not supposed to...
	if fade == nil then
		fade = true
	end
	local character = game.Players.LocalPlayer.Character
	if not character then
		return
	end
	local torso = character:FindFirstChild("UpperTorso")
	if not torso then
		torso = character:FindFirstChild("Torso")
	end
	if not torso then
		return
	end
	if db then
		return
	end
	db = true
	if fade then
		script.Parent.Visible = true
		script.Parent.BackgroundTransparency = 1
		local targ = { BackgroundTransparency = 0 }
		local tween = TweenService:Create(script.Parent, info, targ)
		tween:Play()
		wait(FadeTime)
	end
	if torso then
		local hum = character:FindFirstChild("Humanoid")
		if hum then
			hum.Sit = false
		end
		if typeof(destination) == "Vector3" then
			torso.CFrame = torso.CFrame - torso.CFrame.p + destination
		elseif typeof(destination) == "Instance" then
			if destination:IsA("BasePart") then
				torso.CFrame = destination.CFrame + Vector3.new(0, destination.Size.Y / 2 + 3, 0) --1 for the lower torso, 2 for the legs...
				workspace.CurrentCamera.Focus = torso.CFrame
				workspace.CurrentCamera.CFrame = torso.CFrame * CFrame.new(0, 5, -10)
			end
		end
		if fade then
			wait(BlackoutTime)
		end
	end
	if fade then
		local targ = { BackgroundTransparency = 1 }
		local tween = TweenService:Create(script.Parent, info, targ)
		tween:Play()
		wait(FadeTime)
		script.Parent.Visible = false
	end
	wait(DelayTime)
	db = false
end)
