Hi,

I am trying to make a nametag system for one of my games, and it works, but I am having one problem: I can't figure out how to make the nametag shrink as the camera gets farther away from it.

My code:

game.Players.PlayerAdded:connect(function(player)
	repeat wait() until player.Character
	
	local bg = Instance.new("BillboardGui")
	bg.Parent = player.Character.Head
	bg.Adornee = player.Character.Head
	bg.Size = UDim2.new(1, 0, 1, 0)
	bg.StudsOffset = Vector3.new(0, 2, 0)
	 
	local frame = Instance.new("Frame")
	frame.Parent = bg
	frame.Size = UDim2.new(1, 0, 1, 0)
	frame.BackgroundTransparency = 1
	frame.BackgroundColor3 = Color3.new(1, 1, 1)
	 
	local text = Instance.new("TextLabel")
	text.Parent = frame
	text.Position = UDim2.new(0.25, 0, 0.25, 0)
	text.Size = UDim2.new(0.5, 0, 0.5, 0)
	text.Text = player.Name
	text.TextColor = BrickColor.new("Bright green")
	text.FontSize = Enum.FontSize.Size24
	text.BackgroundTransparency = 1
end)

Does anyone know how I would make the tag shrink/grow bigger as the camera moves further away/closer to it? I considered making an invisible part, but I'm not sure that would work

Thanks.