How to get speaker from TextChatService?

local TextChatService = game:GetService("TextChatService")
TextChatService.OnIncomingMessage = function(textChatMessage)
	if not textChatMessage.TextChannel then return nil end
	if textChatMessage.Status == Enum.TextChatMessageStatus.Success then
		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 overrideProperties = Instance.new("TextChatMessageProperties")
			local Tbl = string.split(textChatMessage.Text, " ")
			local name = Tbl[2]
			local Money = Tbl[3]
			if tonumber(Money) > 10000 then
			return end
			overrideProperties.Text = "ㅤ"
			game.ReplicatedStorage.OnChattedCommand:FireServer("Pay",name,Money) -- firing #Players:GetChildren() times, but I want it fire only 1 time
			return overrideProperties
		end
	end
end
1 Like

I want to make this:
if TextChatMessage.PlrWhoSaid ~= game.Players.LocalPlayer then return nil end

if message.TextSource then
    local sender = game:GetService("Players"):GetPlayerByUserId(message.TextSource.UserId)
end
1 Like

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