Text chat service working 2 times on 1 onCommingMessage

here my code:

local prefix = "/"
local MeCommand = "me"
local PayCommand = "pay"

local TextChatService = game:GetService("TextChatService")
TextChatService.OnIncomingMessage = function(textChatMessage)
	if not textChatMessage.TextChannel then return nil end
	if string.sub(textChatMessage.Text, 1, 1) ~= "/" then return end

	if string.sub(textChatMessage.Text, 2, 3) == MeCommand then
		local overrideProperties = Instance.new("TextChatMessageProperties")
		overrideProperties.Text = string.format("<font color='#ff1880'>%s</font>", 
			string.sub(textChatMessage.Text, 5))
		return overrideProperties

	elseif string.sub(textChatMessage.Text, 2, 4) == PayCommand then
		local Tbl = string.split(textChatMessage.Text, " ")
		local name = Tbl[2]
		local Money = Tbl[3]

		if tonumber(Money) > 10000 then return end
		game.ReplicatedStorage.OnChattedCommand:FireServer("pay")
	end
end
1 Like
if textChatMessage.Status == Enum.TextChatMessageStatus.Success then

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.