Bug Report: DefaultChatSystemChatEvents Infinite Yield Issue

Bug Report: DefaultChatSystemChatEvents Infinite Yield Issue

Hello everyone,

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!


Figures:


Figure 2 - Chat Appearance
Figure 3 - Message Display

I can’t find ChatScript and DefaultChatSystemChatEvents in my game. It means you added both instance in your game. Is it right?

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.

This is a part of the Legacy chat system, you need to switch back to it if you intend to do it this way.

image

Yes, I already have it like that but I still getting an error every so often that it cannot find the default events that roblox makes.

Could it be just lag? have u tried adding a timeout to ur WaitForChild?

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.

Changed the scripts

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.

I still believe it could be lag, but… did your new code fix it?

I won’t know until later if it works fine in the studio; the problem occurs in the game.

Why do you need the legacy chat system either way?

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.

This did not solve my problem I do not know what is happening.

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