Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you make a special chat tag if someone owns a certain gamepass?

For example, if someone says something in the chat, their name will show up as "[VIP]" and then their name. I've seen a lot of games that have this feature. I just can't figure out how you add the tag to the player's name. If one of you know how to script quite well, it would be kind to help me with this.

Here's what I've tried:

game.Players.PlayerAdded:Connect(function(player)
	local tags = Instance.new("Folder", player)
	tags.Name = "Tags"
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
		local newTag = Instance.new("IntValue", tags)
		newTag.Name = "VIP"
		local chatColor = Instance.new("Color3Value", newTag)
		chatColor.Name = "ChatColor"
		chatColor.Value = BrickColor.new("Gold").Color
		local tagColor = Instance.new("Color3Value", newTag)
		tagColor.Name = "TagColor"
		tagColor.Value = Color3.fromRGB(239, 184, 56)
	end
end)

3 answers

✓ Accepted answer

Its simple, roblox already have a module script for this.

Example:


-- Server script

local gamepassId = 0 -- Your gamepass id
local service = game:GetService("MarketplaceService")

game.Players.PlayerAdded:Connect(function(player)
	if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then -- check if have gamepass
		
		local tags = { -- table for tags
			{ -- first tag
				TagText = "VIP", -- Tag text
				TagColor = Color3.fromRGB(239, 184, 56) -- TagColor	
			}
		}
		
		local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService) -- Get chat service
		
		-- Get speaker
		local speaker = nil
		while speaker == nil do
			speaker = ChatService:GetSpeaker(player.Name)
			if speaker ~= nil then break end
			wait(0.01)
		end
		
		speaker:SetExtraData("Tags",tags) -- Set tags
		speaker:SetExtraData("ChatColor",Color3.fromRGB(239, 184, 56)) -- Change chat color, and dont use BrickColor.new(...).Color
	end
end)

Wiki page for Char modules: Roblox Wiki - Chat

Hope it helped :D


Solved your problems? put in title [SOLVED] or accept a answer.

1 comment

0

+1, btw you're the first person on this site that I see using ChatService by requiring it from ServerScriptService (that's what i do aswell), rather than by parenting a module to ChatModules under Chat.

?Index the PlayersMessage, then tie it to the message using

newTag..": "..ChatMessage

2 comments

0

Not sure if that

0

is what your asking for but there, if it's not please re explain it to me, i didn't quite understand where you were getting at

First of all, you said just Service without having a variable for it.

Second of all, you didnt assign the tag to the chat system

i dont really know how to assign it to the chat system, but you can probably find it on youtube

This discussion is preserved as it was. New answers, comments, and votes are closed.