Screen to Billboard GUI animated transition

Hi, I thought this would be a cool gimmick and decided to make it. The code is kind of crappy, because I rushed it in ~10 min, but it’s a cool proof of concept :slight_smile:

Place file:
ScreenToWorldGui.rbxl (63,9 KB)

Code:

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
local gui = plrGui:WaitForChild("ScreenGui")
local frame = gui.Frame

gui.Frame.TextButton.Activated:Connect(function()
	local targetPart = workspace.GoHere
	
	local targetScreenPos = workspace.Camera:WorldToScreenPoint(targetPart.Position)
	local conn = game:GetService("RunService").Heartbeat:Connect(function()
		targetScreenPos = workspace.Camera:WorldToScreenPoint(targetPart.Position)
	end)
	
	for i = 0, 1, 0.05 do
		local currentX, targetX = frame.Position.X.Offset, targetScreenPos.X
		local currentY, targetY = frame.Position.Y.Offset, targetScreenPos.Y
		local newX, newY = math.lerp(currentX, targetX, i), math.lerp(currentY, targetY, i)
		frame.Position = UDim2.new(0, newX, 0, newY)
		frame.UIScale.Scale = 1 - i
		task.wait()
	end

	conn:Disconnect()
	
	local billboardGui = Instance.new("BillboardGui")
	billboardGui.Active = true
	billboardGui.Adornee = workspace.GoHere
	billboardGui.AlwaysOnTop = true
	billboardGui.MaxDistance = 1000
	billboardGui.Parent = plrGui
	frame.Position = UDim2.new(0, 0, 0, 0)
	frame.Parent = billboardGui
	
	for i = 0, 1, 0.05 do
		frame.UIScale.Scale = i
		task.wait()
	end
end)
10 Likes