Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a person holding a tool have a nametag?

There are owner nametags that players can have, and tags floating above a players head. I was wondering how do I make it so when a player is holding a tool, they have a nametag above their head, but when they lose it, it disappears.

1 answer

For something like this, you would need to listen for two events.

local tool = script.Parent
tool.Equipped:Connect()
tool.Unequipped:Connect()

You need to connect these events to two functions that create and destroy the label.

Example:

local Players = game:GetService("Players")

local tool = script.Parent

tool.Equipped:Connect(function()) 
	local char = tool.Parent.Parent

	local tag = Instance.new("BillboardGui")
	tag.Parent = char:WaitForChild("Head")
end)

tool.Unequipped:Connect(function()
	local char = Players:GetPlayerFromCharacter(tool.Parent.Parent)
	if (not char) then return end 
	local tag = char:FindFirstChildOfClass("BillboardGui")
	if (tag) then 
		tag:Destroy()
	end
end)

This is just a rough example, as a demonstration. Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.