Chat Nametags not being given to specific players, only 1 on the list

Hi, I’m trying to make it so that if the player is on the list, they have a special nametag however, it only gives it to 1 player that is on the list not the others. Here is my code:

Configuration

--[[
	
	READ THE "Instructions (Read Me)" BEFORE YOU EDIT THIS
	
--]]

return {

["Settings"] = {
	["Stack Tags"] = false,
	["Game Creator Chat Tag"] = false,
	["Game Creator Chat Color"] = false,
	["Script Creator Chat Tag"] = "Contributor",
	["Script Creator Chat Color"] = "Admin Yellow",
},

["Possible Chat Tags"] = {
	["Owner"] = {
		TagText = "Owner",
		TagColor = Color3.fromRGB(170, 0, 0),
		Priority = 10,
	},
	["Developer"] = {
		TagText = "Developer",
		TagColor = Color3.fromRGB(16, 232, 210),
		Priority = 9,
	},
	["Moderator"] = {
		TagText = "Moderator",
		TagColor = Color3.fromRGB(47, 196, 57),
		Priority = 8,
	},
	["Contributor"] = {
		TagText = "Contributor",
		TagColor = Color3.fromRGB(255, 0, 100),
		Priority = 7,
	},
	["Tester"] = {
		TagText = "Tester",
		TagColor = Color3.fromRGB(255, 0, 0),
		Priority = 6,
	},
	["VIP"] = {
		TagText = "VIP",
		TagColor = Color3.fromRGB(255, 170, 0),
		Priority = 5,
	},
	["Roblox Staff"] = {
		TagText = "Roblox Staff",
		TagColor = Color3.fromRGB(255, 85, 85),
		Priority = 4,
	},
	["Roblox Star"] = {
		TagText = "Roblox Star",
		TagColor = Color3.fromRGB(255, 170, 0),
		Priority = 3,
	},
	["Roblox QA"] = {
		TagText = "Roblox QA",
		TagColor = Color3.fromRGB(40, 110, 190),
		Priority = 2,
	},
	["Roblox DevForum"] = {
		TagText = "Roblox DevForum",
		TagColor = Color3.fromRGB(255, 170, 0),
		Priority = 1,
	},
},

["Possible Chat Colors"] = {
	["Developer Blue"] = {
		ChatColor = Color3.fromRGB(16, 232, 210),
		Priority = 2,
	},
	["Intern Blue"] = {
		ChatColor = Color3.fromRGB(175, 221, 255),
		Priority = 1,
	}
},

["Assigned Chat Tags"] = {
	["Players"] = {
		{
			-- Nicholas_Foreman, creator of this script
			UserId = 34355831, 101894318, 153699426,
			Tags = {"Developer"},
			print("Developer tags are distributed")
		},
	},
	["Groups"] = {
		{
			-- Example group with rank
			GroupId = 2717224,
			Rank = 255,
			GroupRankComparison = ">=",
			Tags = {"Owner"},
		},
		{
			-- Roblox Admins group (do not remove)
			GroupId = 1200769,
			Rank = nil,
			GroupRankComparison = nil,
			Tags = {"Roblox Staff"},
		},
		{
			--- Roblox Interns group (do not remove)
			GroupId = 2868472,
			Rank = 100,
			GroupRankComparison = ">=",
			Tags = {"Roblox Staff"},
		},
		{
			--- Roblox Stars group
			GroupId = 4199740,
			Rank = nil,
			GroupRankComparison = nil,
			Tags = {"Roblox Star"},
		},
		{
			--- Roblox QA group
			GroupId = 3055661,
			Rank = nil,
			GroupRankComparison = nil,
			Tags = {"Roblox QA"},
		},
		{
			--- Roblox Developers Forum group
			GroupId = 3514227,
			Rank = 2, -- Members only ♥
			GroupRankComparison = ">=",
			Tags = {"Roblox DevForum"},
		},
	},
	["GamePasses"] = {
		{
			-- Example VIP gamepass
			GamepassId = 6026595,
			Tags = {"VIP"},
		},
	},
	["Badges"] = {
		{
			-- Example Tester badge
			BadgeId = 336132652,
			Tags = {"Tester"},
		},
	},
	["Teams"] = {
		{
			-- Example team
			TeamName = "Team",
			Tags = {"VIP"},
		},
	},
},
		
["Assigned Chat Colors"] = {
	["Players"] = {
		{
			--- Nicholas_Foreman, creator of this script
			UserId = 34355831, 101894318,
			ChatColor = "Developer Blue",
		},
	},
	["Groups"] = {
		{
			-- Example group with rank
			GroupId = 2717224,
			Rank = 255,
			GroupRankComparison = ">=",
			ChatColor = "Admin Yellow",
		},
		{
			-- Roblox Admins group (do not remove)
			GroupId = 1200769,
			ChatColor = "Admin Yellow",
		},
		{
			-- Roblox Interns group (do not remove)
			GroupId = 2868472,
			Rank = 100,
			GroupRankComparison = ">=",
			ChatColor = "Intern Blue",
		},
	},
	["GamePasses"] = {
		{
			-- Example VIP gamepass
			GamepassId = 6026595,
			ChatColor = "Admin Yellow",
		},
	},
	["Badges"] = {
		{
			--- Example Tester badge
			BadgeId = 336132652,
			ChatColor = "Admin Yellow",
		},
	},
	["Teams"] = {
		{
			-- Example team
			TeamName = "Team",
			ChatColor = "Admin Yellow",
		},
	},
},
		
}

LOOK FOR ASSIGNED CHAT TAGS
Thank you for the help!

1 Like

The problem is right here

	["Players"] = {
		{
			-- Nicholas_Foreman, creator of this script
			UserId = 34355831, 101894318, 153699426,
			Tags = {"Developer"},
			print("Developer tags are distributed")
		},
	},

You’re trying to set UserId to that first ID. That wants it in the form of a table for each player. The same goes for the chat colors farther down.

	["Players"] = {
		{
			-- Nicholas_Foreman, creator of this script
			UserId = 34355831,
			Tags = {"Developer"},
			print("Developer tags are distributed")
		},
		{
			-- Nicholas_Foreman, creator of this script
			UserId = 101894318,
			Tags = {"Developer"},
			print("Developer tags are distributed")
		},
		{
			-- Nicholas_Foreman, creator of this script
			UserId = 153699426,
			Tags = {"Developer"},
			print("Developer tags are distributed")
		},
	}

This would be the fixed code for what you’re trying to do. Because currently it was setting UserId = 34355831, then 101894318 to an index, and 153699426 to an index (I think they were just going to 1 and 2 but I could be wrong.

It would be easier to just set the Developer tag to a specific rank and higher in a group if it’s a group place.

3 Likes

The fix doesn’t have to be specifically splitting a possible table into different parts. Either way you would have to run some sort of for loop in order to find the correct UserID that you want. The problem is definitely you trying to assign mutliple UserId’s to one variable. The following fix should help:

["Players"] = {
	{
		-- Nicholas_Foreman, creator of this script
		UserId = {34355831, 101894318, 153699426}, --- This would be better off as a table
		Tags = "Developer", ---Unless you pick randomly from multiple tags this should just be quotes
		print("Developer tags are distributed")
	},
},

This would help you in both your "Assigned Chat Tags" and "Assigned Chat Colors" tables for Players. The next thing you would have to do is run a loop to test for the correct ID or if an ID is part of the table.

local tag = ""
for i, v in pairs(module["Assigned Chat Tags"].Players.UserID) do
     if v == ID then
          tag = module["Assigned Chat Tags"].Players.Tags
     end
end

This for loop would basically be the same for "Assigned Chat Colors", you would just have to alter certain things. As well, v == ID, ID refers to the Player ID you are trying to find/test for.

1 Like

The code is already in a module and was already designed for the code I sent. That’s why I changed it how I did.

That’s kind of the point of the main table being “Players” in the dictionary, and then having a table of data for each user.

Either way you would have to filter through a table. The [“Players”] is a table. Splitting into multiple tables within the table doesn’t change the situation either way. If you are trying to set a different tag for each Developer then it would be beneficial to split them, but from the code they are not. It’s just repetitive code. The only difference for getting the data would be this by using your code:

local tag = ""
for i, v in pairs(module["Assigned Chat Tags"].Players) do
     if v.UserId == ID then
          tag = module["Assigned Chat Tags"].Players.v.Tags
     end
end

Whichever way that OP uses would have to filter through a table and test UserId’s. On top of that, as far as I know, Tags = {"Developer"}, is returning a table which means you would have to do Tags[1] when retrieving the tag. That is why I also changed that to quotes, but I might be wrong in that.

Did you not read what I sent? (Sorry if that sounds aggressive, not trying to mean it like that)

The script is a module, which is already required by a script. He’s using someone’s pre-made chat tag handler. It already handles everything and loops through everything.

Also, the Tags={"TagTextHere"} gets handled and creates a tag for the player for each of the strings in the table. (I’m assuming this.)

If he is using a pre-made handler then that would work depending on the code and that’s my bad. The reason I changed mine like that is because it would seem like more sense to set it up as such rather than splitting it.

Which is why I said

That would make it so each person in the dev group would have the tags and you wouldn’t have to add or remove each person if the dev team changed.

Right, but I think considering every ROBLOX group that comes to mind was set-up in there and not a group of their own (unless that Example Group was changed to that), then I would think there would be a group for that. Either way, either code would most likely work depending on the script that is requiring the module.