Help with chat tag script

Hello I need help making this script automatic for a group with ranks it the ranks are 200, 212, 214, 215 and 255. This is a chat tag.


local players = game:GetService("Players") --Just the players tab in game.Players
local OwnerID = 2213449830 --Which is this case is dyleddie that I saw from your post
local GamepassId = 31021147 --The gamepass ID
local MarketplaceService = game:GetService("MarketplaceService") --MarketplaceService
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService")) --ChatService

--Tag you get if you own the gamepassId
local VIPChatTag = {TagText = "🌹vip🔥", TagColor = Color3.fromRGB(255, 255, 0)}

--Custom Tags for specific players
local tags = {
	[OwnerID] = {TagText = "Owner", TagColor = Color3.fromRGB(255, 0, 0)},
	[175704610] = {TagText = "Developer", TagColor = Color3.fromRGB(85, 255, 255)},
}


--Script that adds the tag to ther user.
chatService.SpeakerAdded:Connect(function(playerName)
	local speaker = chatService:GetSpeaker(playerName)
	local player = game.Players[playerName]

	if tags[player.UserId] then
		print("Player has a custom chat tag!")
		speaker:SetExtraData("Tags",{tags[player.UserId]})
	elseif MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
		print("Player owns the gamepass!")
		speaker:SetExtraData("Tags", {VIPChatTag})
	else
		print("Request Denied.")
	end
end)

I really need this script.

1 Like

Looking at the script snippet, I think you could use a check to make sure the player has the rank specifically, using a

if player:GetRankInGroup(Group) == 200 then
speaker:SetExtraData(“Tags”,(Tag here))

Should help it. But this may not work for the intended purpose as it doesn’t check it multiple times, so check a table to find the data, like so:

--Variable
local allowedRanks = {
    [200] = true,
    [212] = true,
    [214] = true,
    [215] = true,
    [255] = true,
}

--Function
function check(plr)
    for _,rank in ipairs(allowedRanks) do
        if rank == plr:GetRankInGroup(groupId) then
            return true
        end
    end
    return false
end

To check the player with the function, just write “check(player)” in the function, and check to make sure it returns true. where it would look something like this:

chatService.SpeakerAdded:Connect(function(playerName)
	local speaker = chatService:GetSpeaker(playerName)
	local player = game.Players[playerName]

	if tags[player.UserId] then
		print("Player has a custom chat tag!")
		speaker:SetExtraData("Tags",{tags[player.UserId]})
	elseif check(player) == true then
		speaker:SetExtraData("Tags",{TagText = "Developer", TagColor = Color3.fromRGB(85, 255, 255)})
	elseif MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
		print("Player owns the gamepass!")
		speaker:SetExtraData("Tags", {VIPChatTag})
	else
		print("Request Denied.")
	end
end)

Alternatively, I would recommend doing a function to automate tags, so tags would be easier to create.

1 Like

Sure, I can help you modify this script to automatically give chat tags to players based on their group rank. Here’s how you can do it:

local players = game:GetService("Players")
local GroupId = 123456 --Replace this with your group's ID
local GroupRoles = {200, 212, 214, 215, 255} --List of group roles that should receive the chat tag
local GamepassId = 31021147
local MarketplaceService = game:GetService("MarketplaceService")
local chatService = require(game.ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local VIPChatTag = {TagText = "🌹vip🔥", TagColor = Color3.fromRGB(255, 255, 0)}

chatService.SpeakerAdded:Connect(function(playerName)
	local speaker = chatService:GetSpeaker(playerName)
	local player = game.Players[playerName]

	--Check if the player's group rank is in the GroupRoles list
	local isInGroup = false
	local playerGroups = players:GetUserGroupsAsync(player.UserId)
	for _, group in ipairs(playerGroups) do
		if group.GroupId == GroupId and table.find(GroupRoles, group.RoleId) then
			isInGroup = true
			break
		end
	end

	if isInGroup then
		speaker:SetExtraData("Tags", {{TagText = "Group Member", TagColor = Color3.fromRGB(0, 255, 0)}})
	elseif MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId) then
		speaker:SetExtraData("Tags", {VIPChatTag})
	end
end)

In this modified script, you can replace the GroupId variable with your group’s ID, and modify the GroupRoles list to include the role IDs of the ranks that should receive the chat tag.

The script checks the player’s group membership and rank, and if they belong to the specified group and have one of the specified ranks, it will apply a “Group Member” chat tag to their messages. If they own the specified game pass, the “VIP” chat tag will be applied instead.

2 Likes

Can you set the script up for me? I do not know how to do it.
Thank you.
By the way, please make it automatic, so if you’re in the rank it gives you the tag.