How to create simple chat commands

Hello! This article will show you how to make your own basic chat command system! It is completely beginners friendly but you will need some knowledge about Roblox Studio. As an example, we will make a kick command.

Step 1

Start by inserting a script into ServerScriptService. Why? Because exploiters are unable to get access to scripts in there. Name the script whatever you want


Step 2

Open the script. Let's start by detecting when a player is joining.


Step 3

Now let's check if the player that joined should have access to the chat commands. We'll do that by checking their UserId.

Change the ids to the ids of the players you want to get access to the commands. You can add as many as you want as long as you add an "or" between them.

Step 4

Now let's detect when the player has chatted.


Step 5

Now, let's find out what part of the message is the command. And separate it from the rest...


...and also find the player's name.

Step 6

Now let's see if the command is ":kick" (or the command you want)...

...and check if a player with the name given is in the server.

Step 7

Finally, let's kick the player.

Full script:

game.Players.PlayerAdded:Connect(function(PlayerWhoJoined)

if PlayerWhoJoined.UserId == 12345678 or 87654321 then

PlayerWhoJoined.Chatted:Connect(function(Message)

local Command = Message:match(":%w*")

Message = Message:gsub(":%w*", "")

local name = Message:match("%w*_%w*") or

Message:match("%w+")

if tostring(Command:lower()) == tostring(":kick") then

if game.Players:FindFirstChild(name)then

game.Players[name]:Kick()

end

end

end)

end

end)