Custom Admin commands admin game

  1. What do you want to achieve?
    I made a game for admin with custom admin commands, and i made it so if
    someone types a command like “/blind” without “me” or “others” or smth then it will say “missing target in ‘blind’ using default [me]” it should show it to only the person who typed the message
  2. What is the issue?
    I want the message to only show to the person who typed the command but it shows for everyone
  3. What solutions have you tried so far?
    I tried looking for solutions on developer hub and forum even youtube but i did not find one

Here is the code i wrote for the message to show:

local TextChatService = game:GetService(“TextChatService”)
TextChatService.MessageReceived:Connect(function(TextChatMessage)
local Message = TextChatMessage.Text
if Message == “/blind” then
if Player then
local ChatNotification = require(game.ReplicatedStorage:WaitForChild(“ChatNotification”))
ChatNotification.New(“missing target in ‘blind’ using default [me]”, Color3.fromRGB(255, 196, 60), “FredokaOne”)
end
end
end)

How exactly have you implemented your “ChatNotification” module?

1 Like

Its a module script

local ChatNotification = {}
local textchatservice = game:GetService(“TextChatService”)
local Channel = textchatservice:WaitForChild(“TextChannels”):WaitForChild(“RBXSystem”)

local function SystemMessage(info : array)
return ‘<font color="#’…info[“Color”]…‘“><font size=”’…info[“FontSize”]…‘“><font face=”’…info[“Font”]…‘">’…info[“Text”]…‘’
end

function ChatNotification.New(text : string, color : Color3, font : Enum)
Channel:DisplaySystemMessage(

	SystemMessage({
		
		Text = text,
		Font = font,
		Color = color:ToHex(),
		FontSize = "17"
	})
)

end

return ChatNotification

1 Like

https://create.roblox.com/docs/reference/engine/classes/TextChannel#MessageReceived

“Like TextChannel.MessageReceived, fires when TextChannel:DisplaySystemMessage() is invoked on the client, or when the client receives a valid TextChannel:SendAsync() response from the server. This event is only fired on the client.”

You’re publicly sending the message “/blind”, and since each client has a LocalScript that responds to receiving this message, they all send a system message. You need to use proper TextChatCommand instance or only display the system message if the receiver is not the sender. You can do this from the server with TextChannel.ShouldDelieverCallback to stop clients from picking up on the command in the first place

1 Like

I am not exactly sure how to use it in my script can you please explain a little?

1 Like

Idk how scripts work but isnt it supposed to be in object localscript instead normal or module script? But you could try

Is this in a LocalScript? If so and you really want it to be a message-based system, do

if TextChatMessage.TextSource.UserId == game.Players.LocalPlayer.UserId then
    -- [...]
end

instead of just

if Player then
    -- [...]
end

Also, as general advice, if you want to use commands in the TextChatService system, there’s a specific feature for that. You should also require all your modulescripts at the top of your script.