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