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.
- Get the service bro.
local textChatService = game:GetService("TextChatService")
- Now get that object you just created.
local textChatService = game:GetService("TextChatService")
local commandInstance = textChatService["Yourpathtothecommandinstance"]
- 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!