I want to use TextChatService (TextChatCommand), and when I type a special command like “/Tryout,” I don’t want the message bubble to show up. But if I just talk regularly with someone, the bubble should show up like normal. It’s like a secret message bubble that only hides when I use a special command.
I’ve been trying to find a solution with 25 tabs open, but I can’t figure it out. Can someone help me with this?
I already have some code for detecting if i typ ‘/Tryout’ in the chat.
This is supported for sure, I have seen many games do it.
You can disable the automatic chat bubbles with a property (I forget which service) and then have a script send a chat bubble manually when the player chats as long as their message isn’t in a table of commands.
Alternatively, I think you could disable the ui that is put into players’ characters when they chat if a command was detected. (This might not work)
You also might be able to clear the string being sent to chat before it arrives, but I’m not sure how to do that.
I would provide code but I’m on mobile. Hope this helps!
I have no clue how that would work with TextChatCommands, Cuz it makes the textChatCommands automatically. And detecting every single message a player would sent would be a bit overkill. Since there will be around 100/200 players in a server.
You can use a TextChatCommand. They do exactly what you expect.
First create the TextChatCommand as a descendant/child of TextChatService. You can do this in Studio Edit or via a server-side script. Set the PrimaryAlias property to ‘Tryout’
then in a server or local script, use this to detect the command being used:
local TextChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")
TextChatService.theTextChatCommandYouMade:Connect(function(source, text)
local player = Players:GetPlayerByUserId(source.UserId)
print(`{player.Name} said the command {text}!`)
end)
Don’t forget to change theTextChatCommandYouMade to the path to the command you created. I’m unable to test if the code example provided actually works right now, but hopefully it guides you in the right direction!
You know i already do that. I just want to hide the bubblechat above the players head only when a command is fired. When the player is talking normally i want it to be visible
self.TextChatCommand.Triggered:Connect(function (TextSource, String)
local s, e = pcall(function ()
Callback(TextSource, String, self)
end)
if e then
warn("Error with callback: "..e)
end
end)
I don’t think it will display the bubble chat; Here I am using my own admin system, using text chat commands
here is the triggered code if that matters:
TextChatCommand.Triggered:Connect(function(textSource, rawText)
if not textSource then
return
end
local Caller = Players:GetPlayerByUserId(textSource.UserId)
local TextChannel = textSource.Parent :: TextChannel
if not Utilities.IsPlayerAuthorized(Caller, CommandMetaData.Authority) then
return
end
local RawArguments, ParsedArguments = ParseMessage(Caller, rawText, CommandParsers)
local Context = {
Caller = Caller;
RawMessage = rawText;
RawArguments = RawArguments;
Arguments = ParsedArguments
}
local CommandSession = {
TextChannel = TextChannel;
CommandObject = CommandObject;
Context = Context;
}
CommandSessionData[Caller] = CommandSession
if CommandMetaData.ConfirmBeforeExecuting then
ConfirmationRemote:FireClient(Caller, Context.RawMessage)
else
ExecuteCommand(CommandSession)
end
end)