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()
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:
3:
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!