Feedback: should i use BillbaordGuis or normal Gui with the WorldToViewportPoint() function

so I am trying to make a name tag system

local camera = workspace.CurrentCamera
local NameTag = script.Parent.Temp
local NameTagFolder = script.Parent.NameTags
local PlayersFolder = game.Workspace.Players--using another code i place characters into this folder so it counts non player characters too

local Offset = Vector3.new(0,3,0)

local Targets = {}

local function UpdatePlayers()
	NameTagFolder:ClearAllChildren()
	for _,player in ipairs(PlayersFolder:GetChildren())do
		local nameTag = NameTag:Clone()
		nameTag.Text = string.upper(string.sub(player.Name,1,3))
		nameTag.Visible = true
		nameTag.Parent = script.Parent.NameTags
		Targets[player]=nameTag
	end
end

PlayersFolder.ChildAdded:Connect(UpdatePlayers)
PlayersFolder.ChildRemoved:Connect(UpdatePlayers)

game:GetService('RunService').Heartbeat:Connect(function()
	for player,nameTag in pairs(Targets)do
		local HeadPos = camera:WorldToViewportPoint(player:WaitForChild("Head").CFrame.Position+Offset)
		nameTag.Position = UDim2.fromOffset(HeadPos.X,HeadPos.Y)
	end
end)

after I was done a friend of mine pointed out to me that i can use BillBoardGuis to do this instead but should i ?
i want the player’s to beable to press a button and it will show the full name of the players and also change the colors idk if that is possible for BillBoardGuis
but i think that my method might be slow for bad PC (i don’t really know if it is)
should i look into making this using billboardguis ?
please give me feedback

BillboardGuis are way easier in my opinion. Though for them to be interacted with you would need to put it in PlayerGui with the Adornee of it set to the part you want.

You will get a memory leak if you do not remove the player and name tag since they are still being indexed

2 Likes