Chatcommands visibility in the new textchatservice

I was wondering through roblox’s creator docs and stumbled across TextChatService and decided to give it a try and see how it works and I like it an all but I wonder if there is a way that I could make these commands only visible to a few select players?

image

local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
local KickCmd = TextChatService:WaitForChild("kickCommand")
local Mutecmd = TextChatService:WaitForChild("muteCommand")

KickCmd.Triggered:Connect(function(textSource, Message)   
    for i, v in pairs(Players:GetPlayers()) do
        local str = string.split(Message, " ")
        
        local GamePlayers = Players:FindFirstChild(str[2])
        
        if GamePlayers ~= nil then
            GamePlayers:Kick(str[3])
        else
            warn("No players found!")    
        end
    end
end)
1 Like

Am I right in thinking you want these as displayed chat messages?

You can manage the players to see them server-side and then use LocalScripts to manage the visibility client-side.

Server side:

local playersToSee = {"Player1", "Player2"} --names of players who can see it
local event = --make a remote event somewhere accessible
--by both the server and the client


--when firing:
if table.find(playersToSee, player.Name) then
    event:FireClient(player)
end

and client-side:

local tcs = game:GetService("TextChatService")
local event = somewhere:WaitForChild("Event") --remove event directory here

event.OnClientEvent:Connect(function()
    tsc.TextChannels.RBXGeneral:DisplaySystemMessage("Message here")
end)
1 Like

image
I am doing the same thing and to make them only visible to the players i want, i set AutocompleteVisible to be false by default then set it to true on the client for the players that should see them.

1 Like