Mute players with TextChatService

A pretty simple question but hopefully there is an answer! I am creating an admin panel for a group and wondering how to mute players for everyone using TextChatService.

I am aware of the ChatService:MuteSpeaker() method of the legacy chat service but I don’t seem to be able to find a way to server-mute players using TextChatService.

Thanks in advance :slightly_smiling_face:

For clients, try

TextChatService.OnIncomingMessage = function(message: TextChatMessage)
    message.TextSource.CanSend = false
    return message
end

I dont think its possible for server-side

3 Likes

That works, I decided to send a remote to the client when a player is muted so that it can run this code when they talk. Tysm!

1 Like

A better way to do this server side would be to mute any current and future TextSources that match a userId:

local TextChatService = game:GetService("TextChatService")

local function muteUserId(mutedUserId)
    -- listen for future TextSources
    TextChatService.DescendantAdded:Connect(function(child)
        if child:IsA("TextSource") then
            if child.UserId == mutedUserId then
                child.CanSend = false
            end
        end
    end)

    -- mute any current TextSources
    for _, child in TextChatService:GetDescendants() do
        if child:IsA("TextSource") then
            if child.UserId == mutedUserId then
                child.CanSend = false
            end
        end
    end
end

this can run on the server

4 Likes

Aha! This is what I was trying to achieve, seems better to do this type of thing server-side. Thanks!

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