ChatService:AddChannel isn't working as expected

I want to add a channel to the Roblox chat called “MyChannel” that players can /join and /leave. Despite adding the channel, I cannot join it by typing /join MyChannel. I have tried assigning its ChatChannel.AutoJoin and ChatChannel.Joinable to true, but this does not solve the issue.

Is there anything I’m missing? Here’s my Script inside ServerScriptService (the only enabled Script I’ve created):

local chatServiceModule = require(game:GetService("Chat"):WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))

local channel = chatServiceModule:AddChannel("MyChannel")
print(channel.Joinable) --> true

image

1 Like

Have you tried to put a wait?

Yes.

The issue occurred because I was requireing the ChatServiceRunner.ChatService parented to Chat. To use ChatService, you instead need to require the ChatServiceRunner.ChatService parented to ServerScriptService.

Thanks to this article, @gitrog, and @Camper0008 for helping me out.

9 Likes

Can the Error still happen sometimes due to the chat script running slow?

The chat script doesn’t slow down or error when the filter does. The error message only pertains to filters not working as expected. This is quite evident in the manner that, despite messages not appearing, the chat flow still retains its accuracy. Using the AddChannel API has nothing to do with slow filters, it’ll work just fine.

I wasn’t asking about the Filter it doesn’t have anything to do with slowing down the script, I’m asking the problem with the Script, sometimes it still gives out that Error when using it too soon as the Chat Service script still needs to runs

My script did not error. The issue was simply that I was requireing the wrong ModuleScript (inside Chat instead of ServerScriptService).

As I have attempted this myself, I can confirm it does not error.

Just pcall() and use RenderStepped to retry loading the channel.

That’s really ugly


I’m getting Errors from this

ChatService:GetChannel('All')

and this

ChatS:GetChannel(‘System’)

sometimes it would say that the Channel doesn’t exist

this too

CustomChatChannel:MuteSpeaker(plr.Name)

it would say that the speaker doesn’t exist but the Channel.AutoJoin = true

I’m not too familiar with the chat system. Could this code work?

local isSuccessful, channel = pcall(chatService.GetChannel, chatService, "All")
if not isSuccessful then
    repeat until chatService.ChannelAdded:Wait() == "All"
    channel = chatService:GetChannel("All")
end

It’s probably a good idea to create your own support post if you’re having a separate problem.

That’s not a slowed script. That’s just the script not loading. I am quite sure that the modules are loaded immediately after they are added. If this isn’t the case, wrap your functions in protected mode and go until they return a success.