:Clone() Error?

Trying to clone a name tag. It doesn’t work. It doesn’t show an error.

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character
	if char ~= nil then
		
		if char:WaitForChild("Head") then
			local nameTag = script.NametagGui:Clone()
			nameTag.Parent = char.Head
			nameTag.Frame.SizingFrame.Text.Text = player.Name
		end
	end
end)

My best guess is that your character hasn’t loaded so instead of doing an if check use

plr.CharacterAdded:Connect(function(char)
    if char then else return end
       --clone the nametag
end)

full script
game.Players.PlayerAdded:Connect(function(player)
       player.CharacterAdded:Connect(function(char)
                if char then else return end
                --clone the nametag

		if char:WaitForChild("Head") then
			local nameTag = script.NametagGui:Clone()
			nameTag.Parent = char.Head
			nameTag.Frame.SizingFrame.Text.Text = player.Name
		end
	end)
end)

Indentation might be wrong so fix it on your own

1 Like

You forgot function. Oops! :upside_down_face:

1 Like

Your problem would be this. It is waiting for your head in a if statement.
If you are checking to see if a head exists then you are doing it wrong.