How do I stop a user from talking in the chat?

As I am working on something I need to create a command that can mute players in game, meaning they can not talk.

How do I do this? And also how do I undo the effect

2 Likes

By chat you mean text in the chat box …

yes basically. Making it so they cant send messages

1 Like

Well … you could from a local script take away the chat box.

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)

Is there any other way? Cause Im pretty sure hackers(Cause yes there are still some around) could just add it back for instance.

Plus I want to know the best way to do it

Are you using the new or the old chat?

Oh I don’t care about hackers … game has to be popular to get hackers. I’d be happy with just popular.

Mock up of a system: That will need a lot of love.

local bannedPlayers = {}

local function BanPlayer(player)
    table.insert(bannedPlayers, player.UserId)
    player:Kick("You have been chat banned.")
    game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
end

local function IsPlayerBanned(player)
    return table.find(bannedPlayers, player.UserId)
end

game.Players.PlayerAdded:Connect(function(player)
    if IsPlayerBanned(player) then
        player:Kick("You are chat banned and cannot join the game.")
        game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
    end
end)

-- Example usage to ban a player by their UserId (replace with the desired UserId)
local userIdToBan = 123456789
local playerToBan = game.Players:GetPlayerByUserId(userIdToBan)
if playerToBan then
    BanPlayer(playerToBan)
end

Chatting after being chat banned is a dead give away for a permanent game ban.
You could even code that out.

If this is on the client wouldnt this not work? It would disable it for everyone, and not the single player who chatted.

It is only used in local script and it will only remove chat for the local player. Other than editing the real chat module this is the how you could do that. As per what you’re saying I’m not really sure depends how you implement it I guess, I’ve never tried this myself.

Ah so I see I would need to send an event to the client to mute them, thanks then