How to mute a channel in roblox

So i set the TextChatService ChatVersion to legacy and turned on ShowChannelsBar but i want to mute the “All” channel whenever i want to.
How do i do that? Can somebody help

4 Likes

#help-and-feedback:scripting-support

local chatService = require(game.Chat:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local channel = chatService:GetChannel("ALL")
-- channel:MuteSpeaker("Player's Username [String]")
-- channel:UnmuteSpeaker("Player's Username [String]")
3 Likes

would this mute for everybody?

3 Likes

It’s supposed to be put in the client, not server. When paired witha RemoteEvent it could

5 Likes
chatService.SpeakerAdded:Connect(function(speaker)
channel:MuteSpeaker(speaker)
end)

Something like this would work.

5 Likes

sorry for bothering but i cant make it work, if you could explain

3 Likes

I’m not having any errors while running the script, but it does not mute the players when requested.

local chatService = require(game:GetService("Chat"):WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
repeat task.wait() until chatService:GetChannel("All")
local channel = chatService:GetChannel("All")

task.wait(5)
for _, speakerName in ipairs(channel:GetSpeakerList()) do 
	channel:MuteSpeaker(speakerName)
end

This script is supposed to work as a regular script in ServerScriptService, but either they disabled functionality with this or my Roblox is completely bugged. I looked through the actual source code of ChatService and ChatChannel, but lead to the same script as shown above.

My best answer would be to just use TextChatService if you require a muting system as there would be updated documentation on that.

3 Likes

Ah okay, thank you.
I though it would actually mute the player and show a message like when you try to talk in “System”.
Screenshot 2023-07-11 023638

2 Likes

I know what you mean, but the tables for GetSpeakerList and GetChannelList are showing as {}s. This is either not supposed to happen, or Roblox disabled functionality for the forked version of the chat.

4 Likes

looking into the sourcecode, i found the code that adds the channel and by adding this line of code would actually mute the channel.

and theres actually no way to get this channel into another script and mute it there?
Screenshot 2023-07-11 024849

2 Likes

Well, looks like you solved it! It is true that ever since the TextChatService update, you cannot really modify the forked version of the Legacy chat from outside of the source code. What you just sent did in fact work, and to make it so that you can mute and unmute people:

	allChannel.Leavable = false
	allChannel.AutoJoin = true
	
	_G.mutePlayer = function(p)
		for _, speakerName in pairs(allChannel:GetSpeakerList()) do
			if tostring(speakerName):lower() == tostring(p):lower() then
				allChannel:MuteSpeaker(p)
			end
		end
	end
	
	_G.unmutePlayer = function(p)
		for _, speakerName in pairs(allChannel:GetSpeakerList()) do
			if tostring(speakerName):lower() == tostring(p):lower() then
				allChannel:UnmuteSpeaker(p)
			end
		end
	end
-- In a regular script.
repeat task.wait() until _G.mutePlayer 
_G.mutePlayer("playerName")

This is a compromise. You can use _G.mutePlayer() from anywhere in any regular script, but you have to do repeat task.wait() until _G.mutePlayer and _G.unmutePlayer to prevent errors in retrieving the global variables.

3 Likes

is this how its supposed to look like in the script, because i am trying to run it with my name and its not muting me

2 Likes

Yeah that’s how it is supposed to look like. Make sure you use your username and not your display name.

3 Likes

do i have to add anything in this script in order to make it work?

2 Likes

You might want to do it like this just so that it ensures that the player exists:

repeat task.wait() until _G.mutePlayer 

game.Players.PlayerAdded:Connect(function(p)
_G.mutePlayer(p.Name)
end)
3 Likes

I must be doing something wrong because it still wouldn’t mute me, I also get no errors.

2 Likes

Updated the functions like this:

_G.mutePlayer = function(p)
		coroutine.wrap(function() 
			task.wait(3)
			for _, speakerName in pairs(allChannel:GetSpeakerList()) do
				if tostring(speakerName):lower() == tostring(p):lower() then
					allChannel:MuteSpeaker(p)
				end
			end
		end)()
	end

	_G.unmutePlayer = function(p)
		coroutine.wrap(function() 
			task.wait(3)
			for _, speakerName in pairs(allChannel:GetSpeakerList()) do
				if tostring(speakerName):lower() == tostring(p):lower() then
					allChannel:UnmuteSpeaker(p)
				end
			end
		end)()
	end
game.Players.PlayerAdded:Connect(function(p)
	repeat task.wait() until _G.mutePlayer 
	_G.mutePlayer(p.Name)
end)
1 Like

thank you so much! this works flawlessly

1 Like

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