-
**I made a tag system for players but it needs to change chat service version to work
-
**Roblox going to remove legacyChatService so I need to use it on normal version
-- --[[SETTINGS]]--
local dataManager = require(game.ServerScriptService:WaitForChild("ProfileFolder")._ProfileManager)
-- Define tags with both the text and the color
local tagPrefixes = {
Bot = {text = "Bot", color = Color3.fromRGB(0, 255, 255)}, -- Cyan
Hacker = {text = " Hacker", color = Color3.fromRGB(20, 148, 20)}, -- Green
ExPresident = {text = "Ex-President", color = Color3.fromRGB(255, 223, 0)}, -- Yellow
Froigner = {text = "Froigner", color = Color3.fromRGB(255, 255, 255)}, -- White
Yakuza = {text = "Yakuza", color = Color3.fromRGB(136, 8, 8)}, -- Red
Saiyan = {text = "Saiyan", color = Color3.fromRGB(0, 255, 255)}, -- Light Blue
Salty = {text = "Salty", color = Color3.fromRGB(255, 255, 255)}, -- White
Gambler = {text = "Gambler", color = Color3.fromRGB(1, 68, 33)}, -- Dark Green
GrassEnjoyer = {text = "Grass Enjoyer", color = Color3.fromRGB(123, 179, 105)}, -- Grass Green
Curse = {text = "Curse", color = Color3.fromRGB(48, 25, 52)}, -- Dark Purple
HonoredOne = {text = "Honored One", color = Color3.fromRGB(255, 255, 0)}, -- Gold
Senator = {text = "Senator", color = Color3.fromRGB(255, 255, 0)}, -- Gold
Son = {text = "Son] [We saiyans have no limit ", color = Color3.fromRGB(136, 8, 8)}, -- Red + Light Blue
Fool = {text = "Fool", color = Color3.fromRGB(149, 165, 166)}, -- Grey
}
--[[TAG SETUP FUNCTION]]--
local function SetupTags()
spawn(function()
local ChatService = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
-- Tag validity checker
local Tags = {
['CheckValidity'] = function(Player)
if not Player then return end
local profile = dataManager.Profiles[Player]
-- Check if the player's name is "Yduh981"
if Player.Name == "Yduh981" then
-- If the player's name matches, assign them the Fool tag
return {
--[[Chat Tag]]--
{
TagText = tagPrefixes.Fool.text,
TagColor = tagPrefixes.Fool.color -- Apply the unique color here
},
--[[PlayerName Colour]]
Color3.fromRGB(255, 255, 255) -- Default name color (can be adjusted per tag if needed)
}
end
if profile then
local equippedTag = profile.Data.EquippedTag
local tagInfo = tagPrefixes[equippedTag] -- Get the tag information (text and color)
-- If the tag is not nil, return the tag data
if tagInfo then
return {
--[[Chat Tag]]--
{
TagText = tagInfo.text,
TagColor = tagInfo.color -- Apply the unique color here
},
--[[PlayerName Colour]]
Color3.fromRGB(255, 255, 255) -- Default name color (can be adjusted per tag if needed)
}
end
end
-- If the tag is nil, return nil so no tag is applied
return nil
end,
}
ChatService.SpeakerAdded:Connect(function(PlayerName)
local speaker = ChatService:GetSpeaker(PlayerName)
local Player = game:GetService("Players")[PlayerName]
local function UpdatePlayerTag()
local TagData = nil
local NameColourData = nil
-- Check tag validity
local Data = Tags['CheckValidity'](Player)
if Data then
TagData = Data[1]
NameColourData = Data[2]
end
if TagData then
if NameColourData then
speaker:SetExtraData("NameColor", NameColourData)
end
speaker:SetExtraData("Tags", { TagData })
else
-- If no tag data is found, make sure no tags are set
speaker:SetExtraData("Tags", {})
end
end
-- Update tag when player chats
local MessageCount = 0
local UpdateEvery = 2
Player.Chatted:Connect(function()
if MessageCount >= UpdateEvery then MessageCount = 0
UpdatePlayerTag()
elseif MessageCount == 0 then
UpdatePlayerTag()
end
MessageCount = MessageCount + 1
end)
end)
end)
end
-- Player added function
game:GetService("Players").PlayerAdded:Connect(function(Player)
local ChatTagStorage = Instance.new("Folder")
ChatTagStorage.Name = "ChatTagStorage"
ChatTagStorage.Parent = Player
end)
-- Initialize the tag system
SetupTags()