Skip to content

ChatHandler giving console error with custom chat prefix containing square brackets. #175

@Garwinium

Description

@Garwinium

HD Admin version: 1.31.8 (newest version according to HD Admin itself)
Image

The error being given:
"ReplicatedStorage.HDAdminHDClient.Modules.ChatHandler:79: malformed pattern (missing ']') "
Image
This error is given on every new chat message.

My script:
(If being copied for testing, the condition that checks if a player is muted via an "invisleaderstats" folder should be removed)

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
	if message.TextSource == nil then return end
	
	local properties = Instance.new("TextChatMessageProperties")
	local player = Players:GetPlayerByUserId(message.TextSource.UserId)
	
	if player.invisleaderstats.Muted.Value == true and player ~= Players.LocalPlayer then
		message.Text = ""
		properties.Text = ""
		message.Translation = ""
		properties.Translation = ""
		message.PrefixText = ""
		properties.PrefixText = ""
		return properties
	end

	properties.Text = message.Text
	properties.Translation = message.Translation
	message.PrefixText = ""
	properties.PrefixText = "[@" .. player.Name .. "]:"
	
	print(properties.PrefixText)
	
	return properties
end

Removing the square brackets from the PrefixText causes the console error to no longer appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions