Allow us to fire the Player.Chatted event manually

I’ve been designing chats for a bit of time now, and I’ve just decided I’d release one as a free model (Or, work on one for that matter) There’s one problem, however: I don’t want to use the built in roblox chat bar, and I want to have compatibility to scripts that listen to Player.Chatted

So what do I propose? Create a Function on the Player class to fire the chat event.
function Player:Chat(string Message, Player recipient)
This method will simply fire the .Chatted event of the Player.

Feedback?

6 Likes

Already possible, check out the new chat system.

Can you direct me to where that is, please? (i.e. lua file, general lines it’s at)

Thanks. Unfortunately I’m getting some issues, the Chatted event isn’t firing. Here’s my LocalScript:

local ChatMain = game:GetService("Chat"):WaitForChild("ChatScript"):WaitForChild("ChatMain")
local moduleApiTable = require(ChatMain)
local MessageSender = require(ChatMain:WaitForChild("MessageSender"))

wait(2)
moduleApiTable.MessagePosted:fire("asdfg")
MessageSender:SendMessage("asdfg", "All")

And here’s the Server script:

game.Players.PlayerAdded:Connect(function (p)
	p.Chatted:Connect(function (m)
		print(m)
	end)
end)

After the LocalScript runs, I don’t get anything in the output.

Edit: I do get a chat in the default chat GUI.

The new chat system is copied to your PlayerScripts inside the player. So you want to require it from

game.Players.[PlayerName].PlayerScripts.ChatScript.ChatMain

That being said, if you don’t want to use those, you can just supply a table to ROBLOX’s end using the new SetCore option, like so:

game:GetService("StarterGui"):SetCore("CoreGuiChatConnections", {ChatWindow = {MessagePosted = BindableEvent}})

where the BindableEvent is what you’ll use to simulate the Chatted event.

1 Like

Did someone say fire?

BRING WATER! QUICK!

sorry, I couldn’t resist

btw, if you can see, I have a firefighter mask on so I can help xd

1 Like

Don’t mean to be a bother, but I’m still not able to get it to work (completely different user, hi). When I do it via requiring ChatMain and attempting to fire MessagePosted, it doesn’t fire Chatted, and I don’t actually know how to do it directly via SetCore. Help? :blush:

EDIT: Nevermind, figured it out.

1 Like

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