VIP chat tag | TextChatService

Hello, I am trying to add VIP to my chat tags. The original script was written by: Katrist

What I have tried.

I have tried using ChatGPT to make it, and… It didn’t work out

The Code it made
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local groupId = # -- Replace with your group ID
local vipGamePassId = ### -- Replace with the VIP game pass ID

local vipTag = "<font color='#ffcc00'>[VIP]</font><font color='#b3b6b7'> "

local function hasChatTag(player)
    return player.PlayerGui:FindFirstChild("Chat") and player.PlayerGui.Chat:FindFirstChild("Frame")
end

local function addChatTag(player, tag)
    local props = Instance.new("TextChatMessageProperties")
    props.PrefixText = tag .. "</font>"
    return props
}

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
    local props = Instance.new("TextChatMessageProperties")

    if message.TextSource then
        local player = Players:GetPlayerByUserId(message.TextSource.UserId)
        local hasVIPGamePass = player:HasPass(vipGamePassId)

        if hasVIPGamePass and not hasChatTag(player) then
            props = addChatTag(player, vipTag)
        end
    end

    return props
end

(Do not use)

Current code:

-- Thank you too @Katrist for Writing the script

local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")

local groupId = ##### -- # Out Just Because

local tags = {
	[255] = "<font color='#F5CD30'>[⚡God]</font><font color='#ff40ff'> ",
	[254] = "<font color='#ff2600'>[🔨Developer]</font><font color='#2b83ff'> ",
	[253] = "<font color='#ff2600'>[🔨Developer]</font><font color='#2b83ff'> ",
	[214] = "<font color='#9c1df0'>[🛠️President]</font><font color='#b3b6b7'> ",
	[212] = "<font color='#9c1df0'>[🛠️Head of Staff]</font><font color='#b3b6b7'> ",
	[203] = "<font color='#2af0be'>[🌴Community manager]</font><font color='#2af0be'> ",
	[202] = "<font color='#9b1df0'>[🛠️Admin]</font><font color='#b3b6b7'> ",
	[200] = "<font color='#e1a9f5'>[🔧Moderator]</font><font color='#b3b6b7'> ",
	[111] = "<font color='#83feec'>[🛠️Affiliate]</font><font color='#b3b6b7'> ",
	[110] = "<font color='#ff8b07'>[🔥Partner]</font><font color='#ffd607'> ",
	[101] = "<font color='#F5CD30'>[⭐️Supporter]</font><font color='#b3b6b7'> ",
	[100] = "<font color='#63e848'>[✨Vip Dog]</font><font color='#b3b6b7'> ",
}

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local player = Players:GetPlayerByUserId(message.TextSource.UserId)
		local rank = player:GetRankInGroup(groupId)

		if tags[rank] then
			props.PrefixText = tags[rank] .. message.PrefixText .."</font>"
		end
	end

	return props
end

So basically what I’m trying to achieve is having a chat tag for VIP, that if somebody has a chat tag, it does not go over it, but if they don’t have a chat tag currently it show.

(Please let me know if that does not make sense)

3 Likes

Don’t rely on ChatGPT too much. 95% of the time it is unreliable. Although I don’t have much experience with textchatservice, here is a tutorial to help.

2 Likes

ChatGPT isn’t something you should rely on. I use the DevForum and Videos to help me out with coding.

local textChatService = game:GetService("TextChatService")
local properties = Instance.new("TextChatMessageProperties")
local groupId = GROUP ID HERE

local tags = {
	[255] = {
		["R"] = 0,
		["G"] = 0,
		["B"] = 0,
		
		["TagName"] = "Owner"
	}
}

textChatService.OnIncomingMessage = function(message: TextChatMessage)
	if message.TextSource then
		local plr = game.Players:GetPlayerByUserId(message.TextSource.UserId)
		local plrGroupRank = plr:GetRankInGroup(groupId)
		
		if tags[plrGroupRank] ~= nil then
			local rankTag = tags[plrGroupRank]
			properties.PrefixText = "<font color = 'rgb(" .. rankTag.R .. "," .. rankTag.G .. "," .. rankTag.B .. ")'>" .. rankTag.TagName .. "</font>  " .. message.PrefixText
		end
	end
	return properties
end

This is a LocalScript that should be in StarterPlayerScript.

I found a video that was made by Itz_FloppyFish and edited the code to make it more compatible with other ranks. If you have any questions, feel free to ask!

2 Likes

Hello @ExploxYT, Thank you for make/finding this script.

Not to be rude, but I kind of asked for a VIP chat tag.

– But Thank you so much.