Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to block a specific user from chatting?

Asked by 3 years ago

Hi how do I ban a user from chatting, thanks

game:GetService("Players").PlayerAdded:Connect(function(Player)
    --Code to determine if player is banned from chatting
    if IsBannedFromChatting then
        --What goes here?
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

If you want to ban multiple people you would use a table, but since chatting is locally you would use a local script which I don't think PlayerAdded Would work on it, so you would put the script on player scripts. Having the chat disabled or muted would use the StarterGui which has a function that you can used called SetCoreGuiEnabled which has a lot of uses but for this instance we will turn off the chat, which SetCoreGuiEnabled needs two inputs, the thing you want to alter and the if you want it on or off or true or false, in this case if you don't know them on the top of your head you would use Enum.CoreGuiType. , so it would bring you to a select or dropdown on the things you can choose from, Here is the Code I used that uses what I just said.

local MutedPeople = {"Rayguyban2", "PlayerName"}
local player = game.Players.LocalPlayer
-- Table for List of muted people


local StarterGui = game:GetService("StarterGui")

for i = 1,#MutedPeople,1 do
    if player.Name == MutedPeople[i] then
        -- Loops through whole table and if the person is on the table and then disables the chat for the player affected
        StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,  false)

    end
end

Ad

Answer this question