How to make this function repeat till the player gets a nametag

Ello devforum community,

i decided to make a costum name tag for my script i watched some tutorial on the internet on how to do it.
It works hoever only somtimes ? when i run test mode sometimes the player dont receive a nametag and sometimes he does. its annoying to stop and repeat play mode till i get a nametag to test stuff.

so my question is how do i make this script repeat till the player gets a nametag ?

--Made by Sheasu | Modified by MightyYaso
--Variables
local rep = game:GetService("ServerStorage")
local nametag = rep.nametag 

--Functions
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		--Varibles
		local head = char.Head
		local newtext = nametag:Clone()
		local plrjob = newtext.plrjob
		local plrname = newtext.plrname
		local plrgrouprank = newtext.plrgrouprank
		local humanoid = char.Humanoid
		
		local fallImpactScript = script.Impact:Clone()
		fallImpactScript.Parent = char.Humanoid
		fallImpactScript.Disabled = false
		
		humanoid.DisplayDistanceType = "None"
		
		--Main Text
		newtext.Parent = head
		newtext.Adornee = head
		plrname.Text = player.Name 
		plrjob.Visible = false
		
		if not player:IsInGroup(6520169) then
			plrgrouprank.Text = "Immigrant"
			plrgrouprank.TextColor3 = Color3.fromRGB(255, 0, 0)
		elseif player:GetRankInGroup(6520169) >= 254 then
			plrgrouprank.Text = "Owner"
			plrgrouprank.TextColor3 = Color3.fromRGB(255, 0, 0)
		elseif player:IsInGroup(6520169) then
			plrgrouprank.Text = "WhoIsYouBoi"
			plrgrouprank.TextColor3 = Color3.fromRGB(255, 0, 0)
		end
	end)
end)

Perhaps the script should wait for the head?

If you want it to repeat, you can always do a while loop. What I mean by this is the while loop will check if the plrgrouptext was filled out or still default text.

while plrgrouprank.Text == "Label" and wait() do
 --if statements and other such code here
end

If that is not the problem, then you can easily move the while loop up and have it set to loop on a different such thing.