Nametag only works for first person in-game

Hi, so I have this nametag script but it only works for the first person who joins the game, and not the other people. The other people will not have a nametag while the first person will.
Here is the script:

plr.CharacterAdded:Connect(function(char)
		--Varibles
		local head = char.Head
		local newtext = nametag:Clone() 
		local uppertext = newtext:WaitForChild("PlayerName")
		local lowertext = newtext.Title
		local humanoid = char.Humanoid
		print(6)
		humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None -- use enum instead of a string

		--Main Text
		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = plr.Name 

		if plr.previoustitle.Value ~= "" then
			lowertext.Text = plr.previoustitle.Value
		end

		--"If" Statements
		--You can add as many of these as you wish, just change it to the player's name.

	end)

This script is inside a player.added function with leaderstats. How can I fix this problem? Thanks!

Hello!

Could you show a bit more of the script, as only the CharacterAdded event is shown?
Also, is this a local or server script (just to make sure)?

Provide the entire script for more context.

Is a server script. I don’t know why you need the whole script because the leaderstats have nothing to do with it.

I do not think this will help you:

ame.Players.PlayerAdded:Connect(function(plr)


	local toolsOwned = {}
	local stylesOwned = {}
	local titlesOwned = {}
	local style = ""
	local title = ""
	local coins = 0
	local wins = 0
	local skips = 0

	local packedData;
	local s, err = pcall(function()
		packedData = ds:GetAsync(plr.UserId)
	end)

	if s then
		plr:SetAttribute('DataSuccess', true)
	else
		print(tostring(err))
	end

	if packedData then
		local s = pcall(function()
			packedData = game.HttpService:JSONDecode(packedData)
		end)
		if typeof(packedData) == 'table' then
			stylesOwned = packedData.Styles or stylesOwned
			titlesOwned = packedData.Titles or titlesOwned
			toolsOwned = packedData.Tools or toolsOwned
			coins = packedData.Coins or coins
			wins = packedData.Wins or wins
			skips = packedData.Skips or skips
			title = packedData.Title or title
		else
			plr:SetAttribute('DataSuccess', false)
		end
	end
	print(3)

	if not plr:GetAttribute('DataSuccess') then
		-- notify the player that their data did not load successfully.
		local msg = Instance.new('Message')
		msg.Name = '__ALEXSMESSAGE'
		msg.Text = 'Failed to load your data. Please rejoin.'
		msg.Parent = plr:WaitForChild('PlayerGui')
		game.Debris:AddItem(msg, 5)
	end
	print(4)
	local ls = Instance.new("Folder", plr)
	ls.Name = "leaderstats"

	local coinsValue = Instance.new("IntValue", ls)
	coinsValue.Name = "Coins"
	coinsValue.Value = coins

	local winsValue = Instance.new("IntValue", ls)
	winsValue.Name = "Wins"
	winsValue.Value = wins

	local skipsValue = Instance.new("IntValue", ls)
	skipsValue.Name = "Skips"
	skipsValue.Value = skips


	local previoustitle = Instance.new("StringValue", plr)
	previoustitle.Name = "previoustitle"
	previoustitle.Value = title

	local previousstyle = Instance.new("StringValue", plr)
	previousstyle.Name = "previousstyle"
	previousstyle.Value = style
	print(5)
	plr.CharacterAdded:Connect(function(char)
		--Varibles
		local head = char.Head
		local newtext = nametag:Clone() 
		local uppertext = newtext:WaitForChild("PlayerName")
		local lowertext = newtext.Title
		local humanoid = char.Humanoid
		print(6)
		humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None -- use enum instead of a string

		--Main Text
		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = plr.Name 

		if plr.previoustitle.Value ~= "" then
			lowertext.Text = plr.previoustitle.Value
		end

		--"If" Statements
		--You can add as many of these as you wish, just change it to the player's name.

	end)

	print(7)

	plr.CharacterRemoving:Connect(function()
		title = plr.Character.Head.Nametag.Title.Text

	end)





	local ownedFolder2 = Instance.new("Folder", plr)
	ownedFolder2.Name = "OwnedTools"

	local ownedFolder3 = Instance.new("Folder", plr)
	ownedFolder3.Name = "OwnedTitles"

	local ownedFolder4 = Instance.new("Folder", plr)
	ownedFolder4.Name = "OwnedStyles"

	for i, owned in pairs(toolsOwned) do

		if tools:FindFirstChild(owned) then

			tools[owned]:Clone().Parent = ownedFolder2
		end
	end

	for i, owned in pairs(titlesOwned) do

		if titles:FindFirstChild(owned) then

			titles[owned]:Clone().Parent = ownedFolder3
		end
	end

	for i, owned in pairs(stylesOwned) do

		if titles:FindFirstChild(owned) then

			titles[owned]:Clone().Parent = ownedFolder3
		end
	end

end)

I do not think this will help you but ok:

ame.Players.PlayerAdded:Connect(function(plr)


	local toolsOwned = {}
	local stylesOwned = {}
	local titlesOwned = {}
	local style = ""
	local title = ""
	local coins = 0
	local wins = 0
	local skips = 0

	local packedData;
	local s, err = pcall(function()
		packedData = ds:GetAsync(plr.UserId)
	end)

	if s then
		plr:SetAttribute('DataSuccess', true)
	else
		print(tostring(err))
	end

	if packedData then
		local s = pcall(function()
			packedData = game.HttpService:JSONDecode(packedData)
		end)
		if typeof(packedData) == 'table' then
			stylesOwned = packedData.Styles or stylesOwned
			titlesOwned = packedData.Titles or titlesOwned
			toolsOwned = packedData.Tools or toolsOwned
			coins = packedData.Coins or coins
			wins = packedData.Wins or wins
			skips = packedData.Skips or skips
			title = packedData.Title or title
		else
			plr:SetAttribute('DataSuccess', false)
		end
	end
	print(3)

	if not plr:GetAttribute('DataSuccess') then
		-- notify the player that their data did not load successfully.
		local msg = Instance.new('Message')
		msg.Name = '__ALEXSMESSAGE'
		msg.Text = 'Failed to load your data. Please rejoin.'
		msg.Parent = plr:WaitForChild('PlayerGui')
		game.Debris:AddItem(msg, 5)
	end
	print(4)
	local ls = Instance.new("Folder", plr)
	ls.Name = "leaderstats"

	local coinsValue = Instance.new("IntValue", ls)
	coinsValue.Name = "Coins"
	coinsValue.Value = coins

	local winsValue = Instance.new("IntValue", ls)
	winsValue.Name = "Wins"
	winsValue.Value = wins

	local skipsValue = Instance.new("IntValue", ls)
	skipsValue.Name = "Skips"
	skipsValue.Value = skips


	local previoustitle = Instance.new("StringValue", plr)
	previoustitle.Name = "previoustitle"
	previoustitle.Value = title

	local previousstyle = Instance.new("StringValue", plr)
	previousstyle.Name = "previousstyle"
	previousstyle.Value = style
	print(5)
	plr.CharacterAdded:Connect(function(char)
		--Varibles
		local head = char.Head
		local newtext = nametag:Clone() 
		local uppertext = newtext:WaitForChild("PlayerName")
		local lowertext = newtext.Title
		local humanoid = char.Humanoid
		print(6)
		humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None -- use enum instead of a string

		--Main Text
		newtext.Parent = head
		newtext.Adornee = head
		uppertext.Text = plr.Name 

		if plr.previoustitle.Value ~= "" then
			lowertext.Text = plr.previoustitle.Value
		end

		--"If" Statements
		--You can add as many of these as you wish, just change it to the player's name.

	end)

	print(7)

	plr.CharacterRemoving:Connect(function()
		title = plr.Character.Head.Nametag.Title.Text

	end)





	local ownedFolder2 = Instance.new("Folder", plr)
	ownedFolder2.Name = "OwnedTools"

	local ownedFolder3 = Instance.new("Folder", plr)
	ownedFolder3.Name = "OwnedTitles"

	local ownedFolder4 = Instance.new("Folder", plr)
	ownedFolder4.Name = "OwnedStyles"

	for i, owned in pairs(toolsOwned) do

		if tools:FindFirstChild(owned) then

			tools[owned]:Clone().Parent = ownedFolder2
		end
	end

	for i, owned in pairs(titlesOwned) do

		if titles:FindFirstChild(owned) then

			titles[owned]:Clone().Parent = ownedFolder3
		end
	end

	for i, owned in pairs(stylesOwned) do

		if titles:FindFirstChild(owned) then

			titles[owned]:Clone().Parent = ownedFolder3
		end
	end

end)

I gave more context so any help is appreciated.

There isn’t anything in leaderstats that hinder the cloning of nametag onto the character so im not sure why this is needed.

So I added a print statement to the characteradded function and it prints the players name everytime somebody joins the game which means the function is working. Maybe it has something to do with the cloning?

Strange. Could you try debugging and see where the code stops running when 2+ players join (for print statements after each line for example)? (if it does)

I did do this. The print statement prints in the characteradded part for the second person but no nametag appears for them.

I figured out the problem. When the nametag gets clones, it disappears from ServerStorage for some reason. How do i fix it?

Could you send the part of the script where the nametag variable is defined?

I tried to change it to serverstorage but it didn’t do anything:

local storage = game:GetService("ServerStorage")
local nametag = storage.NameTag 

Maybe try setting the newtext variable’s parent immediately after nametag is cloned. That might help.

Didn’t work. Thanks for helping tho

Ok im narrowing down the problem. What I have found, is the nametag is only working for me and nobody else. For the other player, the nametag will not clone onto their avatar and I do not know why. Can anybody help me?

I tried rewriting it exactly in a new baseplate and as it turns out, it has nothing to do with the scripts in the shop or leaderstats. The problem resides in the original characteradded function. Can anybody help me with this?

Im just so confused because it only works for me, nobody else.

Didn’t quite get what you mean, did it work in the new baseplate?