Quick question on BillboardGui.PlayerToHideFrom

My addition to a script from the internet does not work:

It is for name tags

game.Workspace.ChildAdded:connect(function(plr)
	local name = plr.Name
	local playerinplayers = game.Players:FindFirstChild(plr.Name)

	plr:WaitForChild("Humanoid").DisplayDistanceType = "None"
	if playerinplayers ~= nil then
		playerinplayers.CanLoadCharacterAppearance = true
		local clone = game.ReplicatedStorage.NameTags:WaitForChild("Name"):Clone()
		clone.Parent = plr.Head
		clone.Adornee = plr.Head

		clone.PlayerToHideFrom = name
-- the line above gives an error ^

		clone:WaitForChild("TextLabel").Text = name
	end
end)

It is a script in ServerScriptService

Fixed:

It has to be
clone.PlayerToHideFrom = playerinplayers

You are hiding it from the player’s name not the player

1 Like
local repstorage = game:GetService("ReplicatedStorage")

game.Workspace.ChildAdded:connect(function(plr)
local name = plr.Name
	local playerinplayers = game.Players:FindFirstChild(plr.Name)
	plr:WaitForChild("Humanoid").DisplayDistanceType = "None"
	if playerinplayers then
		playerinplayers.CanLoadCharacterAppearance = true
		local nametagclone = repstorage:WaitForChild("NameTags"):WaitForChild("Name"):Clone()
		nametagclone.Parent = plr.Head
		nametagclone.Adornee = plr.Head
		nametagclone.PlayerToHideFrom = playerinplayers
		nametagclone:WaitForChild("TextLabel").Text = name
	end
end)
1 Like