Hello I created a script for a chat tag and after I found out that I needed to change my old chat service to a new one I started creating a new text chat service and as I created it I started to enter a message into the chat The chat tag with my name doesn’t come out I don’t know what’s wrong help me fix it here’s the script any help is appreciated
local Players = game:GetService('Players')
local TextChatService = game:GetService("TextChatService")
local MarketplaceService = game:GetService("MarketplaceService")
local gamepassId = 951612800 -- The ID of the gamepass that grants VIP status
-- Function to update the chat tags for a player
local function updateTag(player)
-- Try to find the leaderstats folder and the Status value
local leaderstats = player:FindFirstChild("leaderstats")
local tagText = leaderstats and leaderstats:FindFirstChild("Status")
-- If either leaderstats or Status is missing, exit the function
if not tagText then return end
local color = nil -- Initialize the default color variable
-- Assign a color based on the player's status value
if tagText.Value == "Innocent" then
color = Color3.fromRGB(255, 255, 255)
elseif tagText.Value == "Evil" then
color = Color3.fromRGB(189, 83, 83)
elseif tagText.Value == "Crook" then
color = Color3.fromRGB(255, 75, 78)
elseif tagText.Value == "Assassin" then
color = Color3.fromRGB(77, 11, 14)
elseif tagText.Value == "Demon" then
color = Color3.fromRGB(255, 10, 43)
elseif tagText.Value == "Criminal" then
color = Color3.fromRGB(255, 53, 56)
elseif tagText.Value == "Satana" then
color = Color3.fromRGB(255, 20, 251)
elseif tagText.Value == "Supervillian" then
color = Color3.fromRGB(255, 0, 4)
elseif tagText.Value == "Savior" then
color = Color3.fromRGB(0, 191, 255)
elseif tagText.Value == "Guardian" then
color = Color3.fromRGB(0, 255, 0)
elseif tagText.Value == "Officer" then
color = Color3.fromRGB(0, 229, 255)
elseif tagText.Value == "Defender" then
color = Color3.fromRGB(20, 255, 20)
elseif tagText.Value == "Angel" then
color = Color3.fromRGB(89, 255, 214)
elseif tagText.Value == "Superhero" then
color = Color3.fromRGB(0, 100, 255)
end
-- Define chat properties for the player
local chatProperties = {
NameColor = color, -- Color of the player's name in the chat
Tags = { -- Tags to display next to the player's name
{
TagText = tagText.Value,
TagColor = color
}
}
}
-- Check if the player owns the VIP gamepass
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamepassId) then
-- Insert a VIP tag at the beginning of the Tags list
table.insert(chatProperties.Tags, 1, {
TagText = "👑VIP",
TagColor = Color3.fromRGB(255, 255, 0)
})
-- Set the chat message color for VIPs
chatProperties.ChatColor = Color3.fromRGB(226, 226, 0)
end
-- Find the chat user object in TextChatService
local chatUser = TextChatService:FindFirstChild(player.Name)
if chatUser then
-- Apply all the properties to the chat user
for property, value in pairs(chatProperties) do
chatUser:SetAttribute(property, value)
end
end
end
-- Connect to the PlayerAdded event
Players.PlayerAdded:Connect(function(player)
-- Wait for the player's character to load
player.CharacterAdded:Connect(function()
local leaderstats = player:WaitForChild("leaderstats") -- Wait for leaderstats folder
local status = leaderstats:WaitForChild("Status") -- Wait for the Status value
updateTag(player) -- Update the player's chat tags
-- Listen for changes to the Status value
status:GetPropertyChangedSignal("Value"):Connect(function()
updateTag(player) -- Update the chat tags when the status changes
end)
end)
end)