Help with In-Game Title Hierarchy (simple)

In my game, there are titles for players. Titles consist as follows in order of precedence:

  1. Game Owner

  2. Overseer

  3. VIP

  4. Donor

The Game Owner title is for me, and Overseer is for my community manager. The VIP and Donor titles are both gamepasses. If the player owns the VIP gamepass and the Donor gamepass, the VIP title takes precedence.

By the way, these are located in: StarterPlayer>StarterCharacterScripts>Nametag (script)>BillboardGui>GamepassOwner (TextLabel), Regular (TextLabel), Username (TextLabel)

The problem I’m facing is the implementation of the “Regular” title. I want you to know I made this entire script using ChatGPT 3 and have no scripting knowledge whatsoever. I usually manage to reword what I say and have it eventually spit out something that functions properly–or that I’m at least competent enough to tweak it to work–but for this I’m struggling.

Basically, I want a player to get the “Regular” title if they’re in the group (ID 32857623) and ranked 25. However, if that same person also owns one of the gamepass titles, the gamepass title takes precedence. Normally, the gamepass titles always take precedence. I’ve tried using what ChatGPT gives me but it ends up giving multiple titles at the same time or switching them up. For example, someone in my group at rank 25 was testing for me and ended up receiving the Donor title. I tried to tweak the script again, and this time I had both Game Creator and Regular as a title.

I literally just want the Regular title to be there for people ranked 25 in the group and make it so if they also own one of the gamepass titles, then that gamepass title is priority over the Regular title.

Here is the script that isn’t working properly. I’m sure it’s a really simple fix for someone experienced enough.

wait()

local Char = script.Parent
local nametag = script:FindFirstChild("BillboardGui")
local gamepassOwnerId_Donor = 227839933 -- Donor Gamepass ID
local gamepassOwnerId_VIP = 227840061 -- VIP Gamepass ID
local ownerProfileId = 57639897 -- Profile ID of the special owner player
local priceUserId = 72160286 -- User ID of the "price" player
local groupId = 32857623 -- Group ID
local regularRank = 25 -- The rank that grants the "Regular" title

local Nametagclone = nametag:Clone()
Nametagclone.Parent = Char:FindFirstChild("Head")
Nametagclone.Adornee = Char:FindFirstAncestor("Head")
Nametagclone.Username.Text = Char.Name

local player = game.Players:GetPlayerFromCharacter(Char)
if player then
	if player.UserId == ownerProfileId then
		Nametagclone.GamepassOwner.Text = "Game Creator"
		Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black color
		Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
		Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
	elseif player.UserId == priceUserId then
		Nametagclone.GamepassOwner.Text = "Manager"
		Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Dark gray color
		Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
		Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
	else
		local ownsGamepass_VIP = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_VIP)
		local ownsGamepass_Donor = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_Donor)
		local groupInfo = game:GetService("GroupService"):GetGroupInfoAsync(groupId)
		
		if groupInfo and groupInfo.IsMember then
			local rank = groupInfo.Rank
			if rank == regularRank then
				Nametagclone.Regular = Instance.new("TextLabel")
				Nametagclone.Regular.Name = "Regular"
				Nametagclone.Regular.Text = "Regular"
				Nametagclone.Regular.TextColor3 = Color3.new(0, 0, 200) -- Blue color
				Nametagclone.Regular.Parent = Nametagclone
			end
		end

		if ownsGamepass_VIP then
			Nametagclone.GamepassOwner.Text = "VIP"
			Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(255, 227, 12) -- VIP color
		elseif ownsGamepass_Donor then
			Nametagclone.GamepassOwner.Text = "Donor"
			Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(12, 245, 59) -- Donor color
		else
			Nametagclone.GamepassOwner.Visible = false
		end
	end
end

If it helps, this is the script without the Regular title that was working fine before:

wait()

local Char = script.Parent
local nametag = script:FindFirstChild("BillboardGui")
local gamepassOwnerId_Donor = 227839933 -- Donor Gamepass ID
local gamepassOwnerId_VIP = 227840061 -- VIP Gamepass ID
local ownerProfileId = 57639897 -- Profile ID of the special owner player
local priceUserId = 72160286 -- User ID of the "price" player

local Nametagclone = nametag:Clone()

Nametagclone.Parent = Char:FindFirstChild("Head")
Nametagclone.Adornee = Char:FindFirstAncestor("Head")
Nametagclone.Username.Text = Char.Name

local player = game.Players:GetPlayerFromCharacter(Char)
if player then
	if player.UserId == ownerProfileId then
		Nametagclone.GamepassOwner.Text = "Game Creator"
		Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black color
		Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
		Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
	elseif player.UserId == priceUserId then
		Nametagclone.GamepassOwner.Text = "Overseer"
		Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Dark gray color
		Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
		Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
	else
		local ownsGamepass_VIP = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_VIP)
		local ownsGamepass_Donor = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_Donor)

		if ownsGamepass_VIP then
			Nametagclone.GamepassOwner.Text = "VIP"
			Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(255, 227, 12) -- VIP color
		elseif ownsGamepass_Donor then
			Nametagclone.GamepassOwner.Text = "Donor"
			Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(12, 245, 59) -- Donor color
		else
			Nametagclone.GamepassOwner.Visible = false
		end
		
	end
end
4 Likes

Well one, make sure the id’s are correct, and two, a rblx file/reproduction file would help alot. AND PLEASE DONT USE CHATGPT! I had to stop using it because it made me stupider and actually forget some of my programming knowledge and problem solving.

3 Likes

So many problems with the script but of course that’s because it’s made by ChatGPT
I understand that using ChatGPT is better than spending months of learning how to code for some people, but bear in mind you will have to deal with badly written code, AND wrong made up syntax and API.
In any case the poblem is there no such thing as groupInfo.IsMember, if you want to check whether a player is part of a group or not you need to use IsInGroup Then if you want to check if he has the Regular rank you need to use GetRankInGroup.
Since you don’t know how to code i’ll rewrite the whole script for you :

local player = game.Players.LocalPlayer
local Char = player.Character or player.CharacterAdded:Wait()
local nametag = script:FindFirstChild("BillboardGui")
local gamepassOwnerId_Donor = 227839933 -- Donor Gamepass ID
local gamepassOwnerId_VIP = 227840061 -- VIP Gamepass ID
local ownerProfileId = 57639897 -- Profile ID of the special owner player
local priceUserId = 72160286 -- User ID of the "price" player
local groupId = 32857623 -- Group ID
local regularRank = 25 -- The rank that grants the "Regular" title

local Nametagclone = nametag:Clone()
Nametagclone.Parent = Char:FindFirstChild("Head")
Nametagclone.Username.Text = Char.Name



if player.UserId == ownerProfileId then
	Nametagclone.GamepassOwner.Text = "Game Creator"
	Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Black color
	Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
	Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
elseif player.UserId == priceUserId then
	Nametagclone.GamepassOwner.Text = "Manager"
	Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(0, 0, 0) -- Dark gray color
	Nametagclone.Username.TextColor3 = Color3.fromRGB(255, 227, 12)
	Nametagclone.Username.TextStrokeColor3 = Color3.fromRGB(180, 141, 25)
else
	local ownsGamepass_VIP = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_VIP)
	local ownsGamepass_Donor = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamepassOwnerId_Donor)
	
	if ownsGamepass_VIP then
	Nametagclone.GamepassOwner.Text = "VIP"
	Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(255, 227, 12) -- VIP color
	elseif ownsGamepass_Donor then
		Nametagclone.GamepassOwner.Text = "Donor"
		Nametagclone.GamepassOwner.TextColor3 = Color3.fromRGB(12, 245, 59) -- Donor color
	elseif player:IsInGroup(groupId) then
		Nametagclone.GamepassOwner.Visible = false
		local rank = player:GetRankInGroup(groupId)
		if rank == regularRank then
			local regulartag = Instance.new("TextLabel")
			regulartag.Parent = Nametagclone
			regulartag.Name = "Regular"
			regulartag.Text = "Regular"
			regulartag.TextColor3 = Color3.new(0, 0, 200) -- Blue color
		end
		
	end
end

I don’t have enough info on your textlabels and UI so what i’ve changed is based on what little i got from the script

3 Likes

Thanks so much, you’re a real one

2 Likes