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
What is the issue?
I want the message to only show to the person who typed the command but it shows for everyone
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)
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"
})
)
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
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.