Issue with forking Chat

There is a DevForum article and a DevHub article regarding how to fork the chat should a developer want to. However, there is an unaddressed and perhaps obscure issue here that affects how I fork it.

I have many games in my group that import a single ModuleScript. This makes it easy to edit one model while updating all of the games that use it. There used to be a problem with this that I have since become an expert at solving, having created a module I use in pretty much everything now, especially anything using DataStores. The problem was that a script would have a delay prior to connecting a PlayerAdded listener, so if a player joined the server during that delay period, the listener would not be connected in time to fire for that player. The function would be “missed.”

My solution was to simply run the connected function on both any new joiners by connecting a listener as usual, but also running it on any existing players in the server by just having a loop call the function on each member of game.Players:GetPlayers().

There is a much similar issue with forking the chat. The oft-presented solution to forking the chat is to copy all of the existing stuff in the Chat instance of a running studio testing session, and paste it all in the empty Edit mode Chat instance. However, I want to have this forked Chat imported as a module so multiple games can use the stuff from one source. The problem is exactly the same as outlined above. The time it takes for a module to be imported and installed is simply not fast enough for the first player (and sometimes more) to have the new stuff applied to them, or at the very least, the default behavior undone.

I have no idea what you’re getting at but I’m guessing that:

  1. You are forking the chat module
  2. When you fork the chat module, the PlayerAdded() event does not fire when a player joins before the chat module is forked

In my game I had a similar issue where calling WaitForChild() (with the assumption that you’re forking the Chat module in ServerScriptService) would cause the PlayerAdded() function to not fire when a player joined the server.

What worked for me was that I called the PlayerAdded() function before anything else.

As for forking the Chat, you’ll just have to manually fork it every time you start a new project/place.

The PlayerAdded event not firing in time was an example. The issue with forking the chat is similar but there are no PlayerAdded events here.

This is the issue: the forked chat does not replace the default chat in time for the first players’ clients to utilize the new forked chat. That time is the time it takes for the forked module to be required.


I do understand the convenience of using Packages to do what you’re doing but you’ll probably have to do it manually per-place in order to circumvent the issue.

There’s probably a better solution out there as I’m not too familiar with forking chat the way that you are.

There kinda is no good solution for working around this other than doing PlayerAdded and :GetPlayers() and hooking everything required.

Sometimes the player joins faster than the module is ready,
Sometimes the player joins later and the module is ready.

Best to just absorb both by PlayerAdded event and :GetPlayers()

The tricky part here is

hooking everything required.

The Chat affects a lot of things. There’s a new ScreenGui in PlayerGui, a LocalScript in PlayerScripts, folders and such in ReplicatedStorage, and I’m sure many different things that would be hard to just “undo” before loading a forked script to replace the old one.

I will look into this. I heard of Packages before but didn’t know their purpose. If it does what I need I will get back to you.

Then maybe inform the developer to toggle game.Chat.LoadDefaultChat to off so the game doesn’t load the default chat? I’m not sure if that may make it able to load the module and the DefaultChat forked may hook on to players already ingame once it’s added etc.

I usually keep the forked version of the chat in and if I need new modules added, I drop them in from require.

I am the developer of all of the games, as I said I own the group. The module use is just for ease of synchronicity. I will also look into the LoadDefaultChat setting, though, thanks for mentioning it.

I don’t really know what you mean by the last sentence though.

I copy and paste the forked version of game.Chat of its entirety and paste it into Studio and do my modifications from there.

It seems you just want to make it a module instead so you can update multiple games with your chat module.

The Lua Chat System is intended to be ran independently of your code. If you are looking to port the Lua Chat System into your module loading framework, then you will also need to disable the default chat and set up the components on your own so that it works in the way you expect it to.

While I only somewhat understand what you are trying to do here, don’t force it either. Roblox scripts should run independently of your own systems and should retain their original behaviour. The only time it would be appropriate to integrate the chat system to follow the conventions of your other code is if you were making a completely custom chat system.

You are able to package each part of the Lua Chat System and place them in the Chat service, then update each copy as necessary. If you are using Rojo, then you can turn each component of the Lua Chat System (it’s pure code for the most part, but the BoolValue Instances can also be synced IIRC) into part of your project file and it’d just be a matter of syncing it in.

Furthermore, what parts are you actually editing from the Lua Chat System? You should never fork things that you aren’t actively modifying in whole. The Lua Chat System has a wide variety of API that you can use to customise the system to your liking. You should avoid forking where possible unless it’s necessary that you make the changes. Even then, it also has fallbacks so you can extend upon the system without forking the other components as well.

Could you elaborate on your exact method of resource pulling? Why is it that forking the chat presents a problem for you? If you fork it without stuffing it into other systems, it goes without problem.

1 Like

That’s my naughty habit, I’ll try to lower down my script edits soon.

Although I understand that Roblox’s chat service is designed to be modular without forking it, what I want to do only seems possible with it. I made this thread yesterday stating my goal here.

I want one player to be able to send a message while no other players successfully receive it, kind of like a shadow ban. I want whatever creates this chat feature, whether it’s a somehow-unforked Chat modified by a script as part of a framework, or an entirely forked chat, able to be required just like any other on-site ModuleScript so that all players, joining before or after the module’s requiry, are privy to its effects.

set up the components on your own so that it works in the way you expect it to.

Is there documentation somewhere on how Roblox does this by default?

I am confused by this line

You should never fork things that you aren’t actively modifying in whole.

because I was not aware certain parts could be forked while other behavior could remain default. This is why I was copying over the entire contents of the chat service, every folder and module and such. Assuming I understand you right, is it possible here to only fork certain aspects (such as individual ModuleScripts) that the Chat uses? If so, how?

resource pulling

I’m afraid I don’t know what this is. Assuming you mean how I retrieve the forked chat, it’s just done through requiring an on-site module.

If you fork it without stuffing it into other systems, it goes without problem.

Not sure what this means either. Lastly I do not use Rojo nor do I plan to. Appreciate the replies, all things considered

Ahh, there we go. XY problem. What you want to do is to make a certain feature that extends on the chat system but you aren’t sure how to do that, so you’ve resorted to a different method that requires more complexity than just writing one module. It would be better to open with that. I will reply to that thread containing a potential solution you can work with so this doesn’t go off topic. You don’t really need to fork any part of the chat and you can use existing examples to help make this.

There is no documentation regarding how Roblox sets up the Chat service, no. That process is internal. I’ve yet to be able to find it, it could be baked into the engine or in an obscure CoreScript whose code is not available (it also moves server-side components and the filesystem doesn’t contain all server-acting code for the engine).

Regarding the fork line: it’s exactly as I’ve said. Things that you aren’t modifying should not be forked unless you are majorly editing a part of it or the minor edits you want to make are impossible without forking. The Lua Chat System will fill in for any missing components on its own and you can also tell it to do so. For example, suppose my fork looks like this:


A ClearMessages module already exists by default but I forked it and made my own edits. None of the other components are brought along with it and I have an InsertDefaultModules BoolValue in the CommandModules folder. All missing parts will be inserted by default and InsertDefaultModules allows all the Lua Chat System’s default modules to be added. The default ClearMessages will not be added because I have my own in this folder.

So yes: it’s possible to only fork certain pieces of the chat system. You should never have to fork the entire chat system if you’re only making edits to small parts (e.g. some only edit ChatSettings but fork the entire thing). This is something I actively advocate against and is one of the determining principles for me writing the tutorial Changing chat type and other chat settings without forking.

When referring to resource pulling, I’m trying to get an understanding of what exactly you’re trying to do here such that forking the Lua Chat System has presented you a problem. Typically the method is to copy all the elements from the Chat, paste them and then you’re good, but the problems you listed aren’t representative of this so I’m under the assumption that you’re adding other steps to get the Lua Chat System fired up in your game.

Your experience with the Lua Chat System does not go unappreciated.

I will reply to that thread containing a potential solution you can work with so this doesn’t go off topic.

Now, even more so.

In regards to the XY problem I disagree. While in isolation this thread appears to ignore the original thing I wanted, it was created as a follow-up to my thread from yesterday where my issue was not solved. Looking back though I should’ve mentioned this.

I will definitely be taking a look at the thread you linked regarding modifying the Lua Chat System. Odd that even my suggested threads didn’t show it.