Nametag doesn't clone for 2nd person

Hi! So I have this leaderstats script that clones the nametag in replicated storage onto the player:

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)

Here is the part that clones:

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)

There is one major flaw with it which is the nametag doesn’t clone for the 2nd, 3rd, 4th, etc person in-game. Only the first person who joins the server will have the nametag on their head. I tried to debug it by putting a print statement in the CharacterAdded function and it printed for the 2nd player which means the function is happening but it isn’t cloning. How can I fix this?

I have tried many different things so far but none of them have worked. The weird thing is if I make a server in roblox studio, both clients have the nametag. But in a real game, they do not.

Is it a server script or local script doing the cloning? (yes obvious question but sometimes super simple things can get overlooked and make a problem seem bigger than it actually is)

Is the nametag actually there for the script to clone? maybe it got removed for some unknown reason.

Have you put a print statement after the clone to make sure everything else goes correctly and its just the cloning that failed?

Is the nametag on their head showing that it was cloned and its just not in the right position for whatever reason?

  1. It is a server script in serverscriptservice.
  2. I actually think this is the problem. How do I check this in-game?
  3. Yes, I put a print statement after the function and it plays.
  4. No the nametag isn’t anywhere on their character.

Yep, number 2 is the problem. The nametag disappears from serverstorage.

Make sure you’re moving the clone and not the nametag itself

It is:

	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

There are ones in the shop but those don’t use :Destroy()

have you tried setting the newtext's parent to head immediately after nametag is cloned?

Something that has worked for me on many occasions for whatever reason is to just rewrite it. Redo the nametag stuff and it usually works out, if not pick it apart line by line and write comments for what each line does and how it interacts with other lines to try and visualize any problems.

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. 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?