Hi there! Today, I’ll show you how to create a custom chat tag such as:
[VIP] Stickmasterluke: Hello!
in studio! This is actually pretty simple, but I’ll gie you a step-by-step guide on how to do it.
Step 1
Create a new Script (not LocalScript) inside of ServerScriptService. You can name it what you’d like, but I have named it TagVIP as you can see.
Step 2
You’ll need to supply a variable so we know what the ID of the gamepass you have to buy to get the tag is. In this instance, I’ve named the variable gamepassId
.
local gamepassId = 7004828
local service = game:GetService("MarketplaceService")
Step 3
The computer needs to know to run this when a player joins, and it will take the gamepassId
variable we made before and see if the player owns a gamepass corresponding to that ID.
game.Players.PlayerAdded:Connect(function(player)
if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
Step 4
Now is the fun part! We get to create and customise the tags.
local tags = {
{
TagText = "👑VIP",
TagColor = Color3.fromRGB(0, 255, 255)
}
}
Make sure to change the TagText
variable to anything you’d like, my recommendation is not making it too big as it could block the chat.
You can also change the TagColor
too! change the RGB variable to anything you’d like, such as 214, 213, 150
if you’d like a gold colour!
Step 5
The last part, but the most important. This is the part which actually adds your tag whenever you speak.
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
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)
speaker:SetExtraData("ChatColor",Color3.fromRGB(226, 226, 0))
end
end)
Finished Product
A finished script should look exactly like this:
local gamepassId = 7004828
local service = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(player)
if (service:UserOwnsGamePassAsync(player.UserId, gamepassId)) then
local tags = {
{
TagText = "👑VIP",
TagColor = Color3.fromRGB(0, 255, 255)
}
}
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
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)
speaker:SetExtraData("ChatColor",Color3.fromRGB(226, 226, 0))
end
end)
You can copy and paste this, but I recommend you check out the steps so you know what you are doing and can learn with Lua!
Anyways, I hope this guide can really help you. Have a nice day, and good luck with your game(s)!