I’m JKbings0099, the lead developer for Winter Adventures Inc.. I’ve encountered a recurring bug in my game, and I haven’t been able to pinpoint its source.
The Issue:
Once the Roblox game server starts running, after about 5 to 45 minutes, the chat system seems to break and gets “nuked” (see Figure 1). The error that appears is:
Infinite yeild possible on 'ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")'
There is no script in my game that intentionally removes the default chat system chat events, and I’m using the legacy version of Roblox Chat. The setup looks like this:
Figure 1 shows the developer console
Figure 2 shows how the chat is intended to appear.
Figure 3 shows how the messages are displayed.
Request for Assistance:
I’d greatly appreciate it if a Roblox staff member or someone from the development community could help me figure out the cause of this bug. Any guidance would be extremely helpful!
Default Chat Events are something Roblox adds by default if you play your game in studio and open ReplicatedStorage you can see the default chat events.
I’m not the one calling the wait child when roblox loads the client it tries to find the DefaultChatSystemChatEvents in ReplicatedStorage so I don’t know how to change that. Even if I join a server that has been up for 2 hours it still has issues with finding the Events.
I’ve made some changes to both the Default ChatScript and the ChatMain Module to improve functionality. Below are the details of the modifications:
Changes to Default ChatScript
In the Default ChatScript, I made edits to lines 144 - 151 to improve the handling of the DefaultChatSystemChatEvents folder.
Old Code (Before):
local EventFolder = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
EventFolder.GetInitDataRequest:InvokeServer()
New Code (After):
local EventFolder = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
if not EventFolder then
EventFolder = script.DefaultChatSystemChatEvents:Clone()
EventFolder.Parent = ReplicatedStorage
end
EventFolder.GetInitDataRequest:InvokeServer()
Explanation:
The new code adds a check to see if the DefaultChatSystemChatEvents folder exists in ReplicatedStorage.
If it doesn’t exist, it clones the folder from the script and parents it to ReplicatedStorage.
Changes to ChatMain Module
Similarly, in the ChatMain Module, I’ve made changes to lines 53 - 62 for handling DefaultChatSystemChatEvents.
Old Code (Before):
local DefaultChatSystemChatEvents = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
local EventFolder = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
local clientChatModules = Chat:WaitForChild("ClientChatModules")
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local messageCreatorModules = clientChatModules:WaitForChild("MessageCreatorModules")
local MessageCreatorUtil = require(messageCreatorModules:WaitForChild("Util"))
New Code (After):
local DefaultChatSystemChatEvents = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
if not DefaultChatSystemChatEvents then
DefaultChatSystemChatEvents = script.Parent.DefaultChatSystemChatEvents:Clone()
if ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents") then
DefaultChatSystemChatEvents:Destroy() -- Removes Clone
DefaultChatSystemChatEvents = ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
else
DefaultChatSystemChatEvents.Parent = ReplicatedStorage
end
end
local EventFolder = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents")
local clientChatModules = Chat:WaitForChild("ClientChatModules")
local ChatConstants = require(clientChatModules:WaitForChild("ChatConstants"))
local ChatSettings = require(clientChatModules:WaitForChild("ChatSettings"))
local messageCreatorModules = clientChatModules:WaitForChild("MessageCreatorModules")
local MessageCreatorUtil = require(messageCreatorModules:WaitForChild("Util"))
Explanation:
This updated code checks if DefaultChatSystemChatEvents exists in ReplicatedStorage. If not, it clones the folder and parents it to ReplicatedStorage.
If DefaultChatSystemChatEvents already exists in ReplicatedStorage, it destroys the cloned version to avoid duplication.
Summary
These changes add validation to ensure that the DefaultChatSystemChatEvents folder is properly cloned and stored in ReplicatedStorage, preventing errors if the folder doesn’t exist. This should improve the reliability of chat-related events in your game.
We use it because it works with our chat system and it’s a pain to recode. I know I could recode it to work with the radio system but it’s a project I do not have time for right now.