Help With Error

I need help to get rid of this error ServerScriptService.Folder.HeadUI:25: attempt to index nil with 'Name'

This script copies a name tag for ServerStorage and puts it on the players head.

-- SERVER SCRIPT INSIDE SERVERSCRIPTSERVICE
---> services
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		---> variables
		local NameTagClone = game.ServerStorage.HeadUI:Clone()

		---> main
		NameTagClone.Parent = char.Head
		NameTagClone.Adornee = char.Head

		NameTagClone.UI.NameUI.NameName.Text = char.Name

		if plr.Team == nil then
			NameTagClone.UI.JobUI.JobName.Text = "Player"
		end

		repeat wait() until plr.Team ~= nil

		NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name

		char.Humanoid.DisplayDistanceType = "None"

		game:GetService("RunService").Heartbeat:Connect(function()
			NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name
		end)
	end)
end)

This line is the problem but I don’t now why

NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name
2 Likes

give the serverscriptservice script

Sorry I missed type it is in there

Is there something else wrong with it

According to your error, your player doesn’t have a team

Also you should really not do this

		game:GetService("RunService").Heartbeat:Connect(function()
			NameTagClone.UI.JobUI.JobName.Text = plr.Team.Name
		end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.