[BEGINNER] How to make admin system

Hi Guys , today I’m going to tell you how to make a custom admin system !

I do expect that you know string:match() and string:split()

Let me explain these briefly -

string:match() - It checks the string and checks if something in the string matches in the word you will add in brackets . For example : If you do string:match(“player”) , what it does is it will check if there’s a word in the string which is similar to “player”
Another example -

local match = string:match("Welcome to Roblox !", "Roblox")
print(match) -- Prints Roblox , because in the first argument , which is the string from which to find , and the second argument , which is the string to find from the first one , matches , both have Roblox 

So hope you understand now how it works !

string:split() - It splits the strings into parts . For example : If we do string:split(" ") , what will happen is it will split the string after the character we added as parameter , suppose the string is “I’m Moneypro456789” , then what it will do is it will find the character given as parameter , which is space , for now , and it will split everything before it and after it , then suppose it was “Mon ey” then it was have splitted as 2 words as first is “Mon” and second is “ey” . Hoping it makes sense !

Anyways now to the main topic , our admin system !

Let’s add a code when the player gets added

game.Players.PlayerAdded:Connect(function(player)
   player.Chatted:Connect(function(message) -- This activated when player chats and message is the message player sent
   end)
end)

Now we see one more aspect , as we want admin commands , we may want that only few players can get the benefit of commands . Let’s do that

game.Players.PlayerAdded:Connect(function(player)
  if player.Name == "Moneypro456789" then -- it checks about the player you want to access commands
 player.Chatted:Connect(function(message) -- This activated when player chats and message is the message player sent

   end)
end)

Now , it’s going good so far , now we need to add the command system , I’m going to write about kicking a player

game.Players.PlayerAdded:Connect(function(player)
  if player.Name == "Moneypro456789" then -- it checks about the player you want to access commands
 player.Chatted:Connect(function(message) -- This activated when player chats and message is the message player sent
if message:match("/kick") then
local player = message:split(" ")[2] -- The [2] here is the first word , or you can say the word after the space 
if game.Players:FindFirstChild(player) then -- Checks if the player name you wrote exists
game.Players:FindFirstChild(player):Kick(you can add the reason you want or just leave it) -- Kicks the player if it exists
end
end
   end)
end
end)

I hope you found this tutorial helpful , please note this is just for beginners , it doesn’t work for all aspects or works completely .
If you have any queries , don’t forget to ask !
This is just my 2nd tutorial so I don’t have much experience writing them . Please reply for feedbacks , they are open ! :slight_smile:

Another one you may find interesting -

I’m also a human , so I also need some kind of help in my queries , you may find one of those here and help :smiley:

Thanks for reading , Bye !

14 Likes

Nice tutorial I really like how you explain how to make a system like this to begineers. Keep going :smiley:

1 Like

I suggest that you recommend using UserId’s instead of usernames as those can be changed while a UserId can’t.

1 Like

Yeah, I’m so dumb, I really know about that but didn’t added it I don’t know why :sweat_smile:

1 Like

Thanks for your motivation and feedback :smiley:

2 Likes