TextCommandService

TextCommandService.

What’s Text Command Service?

TextCommandService Is A Module That Helps you to make
Chat Commands Easily.

How To Use It?
First: Click Here To Get The Module!
Place the module in your modules folder or ReplicatedStorage, (it is a replicated module so it must be a descendant of the ReplicatedStorage !)

And create a Script name it whatever you want then
require the ModuleScript

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

TextCommandService Contains 3 Functions:

  • .new() Function
  • .AddAdmins { } Function
  • .CreateDefaultCommands() Function

And Contains 1 Property:
TextCommandService.Settings

Starting With .new() Function
.new() Function Contains 2 Arguments:

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

CommandService.new(
   Table: {string}, AdminOnly: boolean
)

.new() Function creates a command and return a metatable!:

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

local MyCommand = CommandService.new(
  {"DoSomething", "DoSome"}, false
) --> Returns Table

MyCommand Should return a metatable self that has functions:

:BindTo(function()

end)
:ListenToAll { Message: string, Type: number }
:Listen { Message: string, Type: number }
:Destroy()

Example:

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

local MyCommand = CommandService.new({"DoSomething", "DoSome"}, false)
      :BindTo(function(Player,  message)
         --> Your Code Here
end)

Message Argument of Spawned Function is a table of the string that player send ex:
/DoSomething Hello

 print(message[2]) -- Should be Hello```

Message { } Function of metatable Is the Input that gonna send from the server to player ex:

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

local MyCommand = CommandService.new({"DoSomething", "DoSome"}, false)
      :BindTo(function(Player,  message)
         --> Your Code Here
end):Listen { "This Message Will Show only for the player who spawned the function!", 1} -- > FireClient()
       :ListenToAll {"This Message Will show for everyone in the server!" , 2} --> FireAllClients()

image

Types are the colors ex: message, error, success
red = error, success = green, message = white
1 = a regular message;
2 = a success message;
3 = a error message;

2:
image
3:
image

TextCommandService.Settings are a folder that contains values you can edit like:
TextCommandService.Settings.MessagePrefix.Value = “Server”
This will make the message from [ System ]: to: [ Server ]:

And Finally :Destroy()
It’s easy as it’s name it cleans up the command
and destroys it leaving nothing.

And thank you for reading the topic.
This is my first topic in devfourm.

[ Update 1.0.1 ]

Improved Allias System Thanks very much to F3NAI for Telling me to do that

Before:

CommandService.new(
  CommandName: string, PrimaryAllias: string, SecondaryAllias: string, AdminOnly: boolean
)

After:

CommandService.new(
    Aliases: {string}, AdminOnly: boolean
)

You Can Add Infinite Alliases now!

8 Likes

Oh To Add Admins if you enable OnlyAdmin Option:

TextCommandService.AddAdmins {
  (UserId) --> Number
}

CreateDefaultCommands() Function creates a commands that I created by my self.

TextCommandService.CreateDefaultCommands()
1 Like

Well, this will be useful for starter Developers. Thanks for sharing this.

2 Likes

You are right, Thank You for your reply.

1 Like

Looks great! But I think you can change the alias system. Instead of using variables for the aliases, you could make a table that holds all the aliases, that way you can make an infinite amount of aliases.
Example:

local CommandService = require(game.ReplicatedStorage.TextCommandService.Module)

CommandService.new(
  CommandName: string, Aliases: {string}, AdminOnly: boolean
)

That would be:

local MyCommand = CommandService.new(
  "CommandExample", {'Alias1', 'DoSomething', '/Example'}, false
)

And so on!

3 Likes

That’s a great idea thank you.

2 Likes

Update 1.0.1

Improved Allias System Thanks very much to F3NAI for Telling me to do that

Before:

CommandService.new(
  CommandName: string, PrimaryAllias: string, SecondaryAllias: string, AdminOnly: boolean
)

After:

CommandService.new(
  CommandName: string, Aliases: {string}, AdminOnly: boolean
)

You Can Add Infinite Alliases now!

2 Likes

uhh, its broken

1 Like

its not that hard to create a command object and listen to the .triggered event

2 Likes

You are doing it wrong try this:

local MyCommand = CommandService.new(
  "CommandExampe", {"DoSomething", "DoSome"}, false
)

MyCommand.Spawned:Connect(function(player, message)
       MyCommand.Message { 
         Player = player;
         Message = "This is a test";
         Type = 1;
       }
end)
1 Like

It simplifies and organizes progress and provides features including: unlimited number of aliases and also allows sending a message to a person’s chat when interacting with the command

1 Like

I am new to this, what does "CommandExampe", {"DoSomething", "DoSome"}, false do?

1 Like

oh “CommadExampe” is the name of your command
{"DoSomething"m “DoSome”} is the command that you chatted in the chat like I chatted:
DoSome

and in same time the code was running like that

local MyCommand = CommandService.new(
  "CommandExampe", {"DoSomething", "DoSome"}, false
)

MyCommand.Spawned:Connect(function(player, message)
       MyCommand.Message { 
         Player = player;
         Message = "This is a test";
         Type = 1;
       }
end)

The Chat will say:
[ System ]: This is a test 
with a white color

why cant it be changed to a custom name?

you can do that like

local FlyCommand = CommandService.new(
  "FlyCommand", {"/fly", "/f"}, false -- false is a boolean if true it will make the command run for admins only.
)

TextChatService.TextChannels.RBXGeneral:DisplaySystemMessage("[ System ]: "..msg)

1 Like

that sends the message to client you don’t need to know this
just create your command CommandService.new()

oh thanks that really helped

e

1 Like

Ok No problem thanks for using my module.

This is a good new module post, but I think it could fair with more features. You have made me interested in making something like my discord.js framework for Roblox especially now that it has command autocomplete.

2 Likes