How to use the new Lua chat commands

Roblox recently made a new Lua chat system with an easier way to create commands. That’s epic. But how to use it? You ask. There’s no docs so this is a tutorial made by me. I just figured out how to use it so yeah.

Alrighty. First, you can do this manually or with a script. Up to you, create a textChatCommand in a script or manually, and edit its properties, like primaryalias and secondaryalias, then just parent it to textchatservice.

Second, let’s make this command do something! Let’s make a serverscript in serverscriptservice, and follow the steps.

  1. Get the service bro.
local textChatService = game:GetService("TextChatService")
  1. Now get that object you just created.
local textChatService = game:GetService("TextChatService")
local commandInstance = textChatService["Yourpathtothecommandinstance"]
  1. When command trigger, do something!
local textChatService = game:GetService("TextChatService")
local commandInstance = textChatService["Yourpathtothecommandinstance"]

commandInstance.Triggered:Connect(function(plr,chat)
print(plr,chat) -- your code
end)

Plr is the player who sent the message(the player instance itself and not the plr name), chat is basically what player sent.

Yep! That’s it, if I made anything wrong or missed anything, let me know!

Hope this helps!

4 Likes

I mean, this tutorial would be better if you went more in depth to how this works, but given how there isn’t a documentation yet, I can’t blame you.

2 Likes

change this to the player instance so like this:

Plr is the player who sent the message(the player instance itself and not the plr name)

1 Like

Done.