Help with lua chat system

hello, so im trying to write a chat thing where it adds a new speaker every time you chat. the issue is that to add a chat speaker, i must use the chatservice. but idk any way on how I can get the chat service. any help is appreciated.

local Players = game.Players
local FunctionId = "CrossServerMessaging"

local function Say(Speaker, Message, ChatService)
	local NewSpeaker = ChatService:AddSpeaker(Speaker)
	NewSpeaker:JoinChannel("All")
	NewSpeaker:SayMessage(Message, "All", {NameColor = Color3.fromRGB(255, 0, 0)})
end
local function HideMessage(Speaker, Message, Channel, ChatService) 
	Say(Speaker, Message)
	return true
end


local function Run(CS)
	local thing = CS:RegisterProcessCommandsFunction(FunctionId, HideMessage)
	print(thing)
end



return Run

plz help any help is appreciated

You can get chat service (or any other service) by using GetService

local ChatService = game:GetService("Chat")

thats not what i mean. I mean the lua chat system. It has more capability.

image

  • you put a module in the ChatModules folder like so
  • the module should return a function. said function will run at runtime and ChatService will get passed to it.
-- example mode code
return function (ChatService)
    ChatService:RegisterFilterMessageFunction("Test",function(sender, messageObject, channelName)
         -- you can do whatever you want
    end)
end
1 Like

oh wait, why did I never think about that. I was just about to edit chat service just for this one thing. thank you so much <3

No problem.

Remember if you still want to use default chat, make sure to have “InsertDefaultModules” set true. Otherwise you can set it to false (or remove it) and have a fully custom chat.

didn’t know that. thx for the extra info bro.

1 Like