Issues with ChatChannels and ChatService?

I’m a bit confused on how ChatChannels work. I’m trying to make a Dead channel and add players that died to that channel so dead players chat and alive players chat are separated. This works, but players in the Dead channel can just delete the Dead before their message and be back in the main channel.

With this code I’m getting an error on the client chat scripts saying ‘All’ is not a channel:

local PlayersService = game:GetService('Players')
local ChatService = require(game:GetService('ServerScriptService'):WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

local DeadChannel = ChatService:AddChannel('Dead')
DeadChannel.Joinable = false
DeadChannel.Leavable = false
DeadChannel.AutoJoin = false
DeadChannel.Private = true

ChatService.SpeakerAdded:Connect(function(SpeakerName)
	local Speaker = ChatService:GetSpeaker(SpeakerName)

	local Player = PlayersService[SpeakerName]
	local Character = Player.Character or Player.CharacterAdded:Wait()

	Character.Humanoid.Died:Connect(function()
		Speaker:LeaveChannel('All')
		Speaker:JoinChannel('Dead')
		Speaker:SetMainChannel('Dead')
	end)
end)

The ‘All’ channel is from my understanding created by default, but it’s not there for the client.

If anyone can better explain how channels work or what the issue is, it would be very appreciated.

Edit: Exact client error: Players.PluggedByJohn.PlayerScripts.ChatScript.ChatMain.ChatWindow:557: Channel 'All' does not exist.

You might have to manually make a new channel called All.

local AllChannel = ChatService:AddChannel("All")

Doing this says the All channel already exists.

You might have to do this from the server.

It is from the server lol, this entire script is a server script.

Oh, sorry! :rofl:
idk then, maybe try from a client???

Well I can’t require the modules from the client. I’m not sure how I should do this.

I actually saw another person on the DevForum who is encountering the same problem as you, their question has not been answered either. I suggest looking at this:

And also this:

@palarc1 This thread is for chat settings, it’s not an explanation for how to use chat channels.

I think the problem you’re facing here is that you’re using the general channel as your alive channel and you’re confused how leaving works. The All channel is not regarded as a standard channel, rather it’s intended for commonplace communication and (if enabled) echo messages from other channels.

Leaving a channel is not the same as deselecting a speaking channel. The square brackets prefixing the chat indicate which channel your message will be sent to and deleting it defaults to the general channel. Leaving a channel is more akin to self-removal.

What you’ll want to do instead is one of the following:

  • Make an explicit channel for Alive players instead of an explicit Dead channel and use the general channel for all other talk. Reverse who’s considered special. Alive players aren’t the majority so they likewise shouldn’t be granted the main channel.

  • Remove the general channel and make explicit channels for both Alive and Dead players. Don’t use a general channel and opt to control chat flows yourself.

As for removing the general channel, set the GeneralChannelName in your ChatSettings to nil and it won’t be created. You can’t remove it using ChatService APIs.

Thanks for the response! I’m currently trying to set the GeneralChannelName to nil, and I found this snippet on the Client API:

-- Require the ChatSettings module (wait for it to load)
local Chat = game:GetService("Chat")
local ClientChatModules = Chat:WaitForChild("ClientChatModules")
local ChatSettings = require(ClientChatModules:WaitForChild("ChatSettings"))
-- Change settings like you would with any other table.
ChatSettings.MaximumMessageLength = 100

Would I use this to set the GeneralChannelName to nil?

I don’t think you can set the GeneralChannelName to nil. Although it should be

ChatSettings.GeneralChannelName = nil -- or a string with a name if you don't want it to be nil

if this actually can be set in settings.

Yeah, I just tried it and I get 2 errors on the client.

What was the content of these errors?

Players.PluggedByJohn.PlayerScripts.ChatScript.ChatMain.ChannelsBar:241: attempt to index nil with 'lower' and Requested module experienced an error while loading.

I’ve actually made a system that forgoes all the channel stuff. It might help you out.

It’s a bit janky but It works in my testing so far:
Just copy the thing I made here:
Capture2
create a module script named playerstatuscheck as shown above, then paste the code i made down below in it. You will have to edit it to work with your role system though
Make sure insertdefaultmodules is a bool value with the value set to true

local module = {}
local function Run(ChatService)
	local function ProcessMessage(speakerName, message, channelName)
		local speaker = ChatService:GetSpeaker(speakerName)
		local channel = ChatService:GetChannel(channelName)

		if not speaker then return false end
		if not channel then return false end
		if game.Players[speakerName]:FindFirstChild("Role") then -- Check if they have a role
			
				if game.Players[speakerName]:FindFirstChild("Role").Value == "dead" then -- is the role dead?
					for i, plr in pairs(game.Players:GetPlayers()) do -- this loop will only send the message to other dead players
						if plr:FindFirstChild("Role") then -- does the player were going to send the message to have a role?
							if plr:FindFirstChild("Role").Value == "dead" then -- are they dead? if so send them the message
								local speaker = ChatService:GetSpeaker(plr.Name)
								if speaker then
									speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
									speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
								end
							end
						else -- they have no role (there in the lobby), send the message
							local speaker = ChatService:GetSpeaker(plr.Name)
							if speaker then
								speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
								speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
							end
						end
					end
				
					
				else -- they must be alive if there role does not  = dead
				
					for i, plr in pairs(game.Players:GetPlayers()) do -- send the message to ALL players even dead ones
						local speaker = ChatService:GetSpeaker(plr.Name)
						if speaker then
							speaker:SetExtraData("Tags",{{TagText = "Alive", TagColor = Color3.fromRGB(57, 255, 63)}})
							speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
						end
							
					end
				end
			return true
		else -- they have no role, send the message to others without a role and dead players. not alive players
			for i, plr in pairs(game.Players:GetPlayers()) do -- this loop will only send the message to other dead players
				if plr:FindFirstChild("Role") then -- does the player were going to send the message to have a role?
					if plr:FindFirstChild("Role").Value == "dead" then -- are they dead? if so send them the message
						local speaker = ChatService:GetSpeaker(plr.Name)
						if speaker then
							speaker:SetExtraData("Tags",{{TagText = "Dead", TagColor = Color3.fromRGB(126, 126, 126)}})
							speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
						end
					end
				else -- they have no role send it to palyers who also have no role or are dead
					local speaker = ChatService:GetSpeaker(plr.Name)
					if speaker then
						speaker:SetExtraData("Tags",{{TagText = "InLobby", TagColor = Color3.fromRGB(255, 0, 12)}})
						speaker:SendMessage(message, channelName, speakerName, message.ExtraData)
					end
				end
			end

		end
	
		return true
	end

	ChatService:RegisterProcessCommandsFunction("swallow_shadow_ban_chat", ProcessMessage)
end

return Run

1 Like

I have deleted the all channel in the past, and just made my own channels and assigned them based on if the player is alive or not.
Heres how I had it setup.

local chatServiceModule = require(game:GetService("ServerScriptService"):WaitForChild("ChatServiceRunner").ChatService)
chatServiceModule:RemoveChannel("All")
local Players = game:GetService("Players")
local Roundchannel = chatServiceModule:AddChannel("InRound")
Roundchannel.Joinable = false
Roundchannel.Leavable = false
Roundchannel.AutoJoin = false	
Roundchannel.Private = false
local Deadchannel = chatServiceModule:AddChannel("Dead/Lobby")
Deadchannel.Joinable = false
Deadchannel.Leavable = false
Deadchannel.AutoJoin = false	
Deadchannel.Private = true

The game just changes the channels they can speak on by detecting there roles

cc @CAROR567 GeneralChannelName should not be set to nil from the client, do this from the server. In my case typically I have a forked copy of ChatSettings since I add a lot more functionality on top or want the module present in my codebase.

I tried using CTRL + SHIFT + F to find GeneralChannelName in all scripts but I could only find it on the client. I tried forking as well but I get the same errors mentioned earlier in the thread.

was there any solution to this?

There’s rarely a solution to ChatService questions from what I’ve seen (lol).

Jokes aside, I’m attempting to make a similar two-channel chat system at the moment and I’m finding myself becoming frustrated at how little resources there are on ChatService as a whole. So many threads on the topic with either no replies or no solution.