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
#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]")
would this mute for everybody?
It’s supposed to be put in the client, not server. When paired witha RemoteEvent it could
chatService.SpeakerAdded:Connect(function(speaker)
channel:MuteSpeaker(speaker)
end)
Something like this would work.
sorry for bothering but i cant make it work, if you could explain
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.
Ah okay, thank you.
I though it would actually mute the player and show a message like when you try to talk in “System”.
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.
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?
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.
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
Yeah that’s how it is supposed to look like. Make sure you use your username and not your display name.
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)
I must be doing something wrong because it still wouldn’t mute me, I also get no errors.
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)
thank you so much! this works flawlessly
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.