Hello! I am working on a custom chat gui right now and I wanted to know if theres any way of firing the .chatted function when a player chats. I know I can just read the input when the player sends a message but I want to use admin and I believe that relys on the .chatted function. So is there any way I can trigger the .chatted event by using a custom chat module or do I have to create my own admin? Any help is appreciated
The newer chat system, which has a ton more features including the ones you need.
But how would I actually use that to fire the .chatted event?
The documentation tells you exactly how the .Chatted event is fired
Unless you’re referring to Player.Chatted
?
Yes, I am reffering to the player.Chatted event
This seems to be handled by ChatMain modulescript of Roblox’s chat.
--// Sends signal to eventually call Player:Chat() to handle C++ side legacy stuff.
moduleApiTable.MessagePosted:fire(message)
the moduleApiTable is later connected to C++ side using CoreGuiChatConnections SetCore
I don’t recommend doing that, but if you still want to then the solutions are below.
You can either:
- require the ChatMain module and fire the internal event
local message = "Test"
require(game.Players.LocalPlayer.PlayerScripts.ChatScript.ChatMain).MessagePosted:fire(message)
- replace Roblox’s chat bridge (NOTE: This solution completely breaks Roblox’s chat - it gets hidden and is no longer usable)
local chatEvent = Instance.new("BindableEvent")
game.StarterGui:SetCore("CoreGuiChatConnections", {ChatWindow = {MessagePosted = chatEvent}})
-- Line above may error. Make sure to use pcall when using it and retry
chatEvent:Fire("Test")
7 Likes