I’m having this error and not sure how to fix it.
Script:
function module.ChatTag(player, button, frame)
local Players = game:GetService("Players")
local tcs = game:GetService("TextChatService")
local rs = game:GetService("ReplicatedStorage")
local tags_module = require(rs.Game.Modules.Server.tags_module)
local on = false
local tagClicked = false
button.Activated:Connect(function()
on = not on
if on then
button.Image = "rbxassetid://113287267199779"
frame.Visible = true
else
button.Image = "rbxassetid://86158734518876"
frame.Visible = false
end
end)
local function SetupTags()
for _, tag in tags_module.Tags do
if tag then
if player:IsInGroup(tag.Group) and player:GetRankInGroup(tag.Group) >= tag.Rank and not frame.TagHolder:FindFirstChild(tag.Name) then
local button = frame.TagHolder.Template:Clone()
button.Name = tag.Name
button.TextLabel.Text = tag.Name
button.TextLabel.TextColor3 = Color3.fromHex(tag.Color)
button.Visible = true
button.Parent = frame.TagHolder
end
end
for _, CustomTag in tags_module.Custom do
if CustomTag then
if player.UserId == CustomTag.ID and not frame.TagHolder:FindFirstChild(CustomTag.Name) then
local CustomButton = frame.TagHolder.Template:Clone()
CustomButton.Name = CustomTag.Name
CustomButton.TextLabel.Text = CustomTag.Name
CustomButton.TextLabel.TextColor3 = Color3.fromHex(CustomTag.Color)
CustomButton.Visible = true
CustomButton.Parent = frame.TagHolder
end
end
end
end
end
local function OnTagClick(button)
for _, tag in tags_module.Tags do
if tag then
tcs.OnIncomingMessage = function(message : TextChatMessage)
if not message.TextSource then
return
end
local properties = Instance.new("TextChatMessageProperties")
local playerByID = Players:GetPlayerByUserId(message.TextSource.UserId)
properties.PrefixText = "<font color='"..tags_module.Tags[button.Name].Color.."'>"..tags_module.Tags[button.Name].Tag.."</font> "..message.PrefixText
return properties
end
end
end
for _, tag in tags_module.Custom do
if tag then
tcs.OnIncomingMessage = function(message : TextChatMessage)
if not message.TextSource then
return
end
local properties = Instance.new("TextChatMessageProperties")
local playerByID = Players:GetPlayerByUserId(message.TextSource.UserId)
properties.PrefixText = "<font color='"..tags_module.Custom[button.Name].Color.."'>"..tags_module.Custom[button.Name].Tag.."</font> "..message.PrefixText
return properties
end
end
end
end
SetupTags()
for _, button in frame.TagHolder:GetChildren() do
if button:IsA("ImageButton") or button:IsA("TextButton") then
button.Activated:Connect(function()
print("clicked")
tagClicked = not tagClicked
OnTagClick(button)
end)
end
end
frame.RemoveTags.Activated:Connect(function()
tcs.OnIncomingMessage = function(message : TextChatMessage)
if not message.TextSource then
return
end
end
end)
end