Nametag that deletes if player rank is below 1

I have an Auxiliary Police group and i have a nametag for it. How to make this script so that anyone below rank 1 will have their auxiliary police nametag deleted? I don’t want the word “Guest” above players.

My nametag script vv


game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local GuiClone = script.OverheadGui:Clone()
		GuiClone.Parent = Character.Head

		local InformationLabel = GuiClone.Team

		local PlayerRank = Player:GetRoleInGroup(groupId)
		InformationLabel.Text = PlayerRank
	end)
end)

I tried to modify the script

local groupId = 11370451 --REPLACE THIS WITH YOUR GROUPID
local groupRank = 1

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player:GetRankInGroup(groupId) >= 1 then
		local GuiClone = script.OverheadGui:Clone()
		GuiClone.Parent = Character.Head

		local InformationLabel = GuiClone.Team

		local PlayerRank = Player:GetRoleInGroup(groupId)
		InformationLabel.Text = PlayerRank
		elseif Player:GetRankInGroup(groupId) == 0 then
			local GuiClone = script.OverheadGui:Clone()
			local InformationLabel = GuiClone.Team
			InformationLabel.Text = " "
end 
	end)
end)

is this correct?
are there any things to be fixed

do player:GetRankInGroup

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		if Player:GetRankInGroup(groupId) > 0 then
			local GuiClone = script.OverheadGui:Clone()
			GuiClone.Parent = Character.Head

			local InformationLabel = GuiClone.Team
			
			local PlayerRank = Player:GetRoleInGroup(groupId)
			InformationLabel.Text = PlayerRank
		end
	end)
end)

Edit: I didn’t notice your new post, but that should work

1 Like

That script Works! Thanks Kaid3n22