Admin commands for YOUR roblox game!

So admin commands are kind of necessary for a lot of people but hard to understand and hard to add new one. SO to do that I made a very SIMPLE to understand admin command module. Here is how it works.

Step 1 First make a module script in replicatedstorge or anywhere you want

Step 2 Insert this script in the module script

To make the abbreviation possible I use parogrammers this post to help me achieve it.

P.S: I am sure you all can make teleport to and teleport player to your self or to another player command your self

local Commands = {}
local function getplayer(abbreviation)
 for i,v in ipairs(game:GetService("Players"):GetPlayers()) do
  if v.Name:lower():sub(1,abbreviation:len()) == abbreviation:lower() then
   return v
  end
 end
end

local Admins = {} -- Admins that can use the commands

function Commands.AddCommand(Player,Prefix,Name,Function,DoReason)
 Player.Chatted:Connect(function(Message)
  if table.find(Admins,Player.Name) then
   local MSG = Message:split(" ")
   if MSG[1] == Prefix..Name then
    local plrname = MSG[2]
    local reason
    if DoReason  then
     reason = MSG[3]
    end
    if reason == nil then
     reason = "Unknown"
    end
    local plr2dothingwith = getplayer(plrname)
    if plr2dothingwith then
     if DoReason then
      Function(Player,reason)
     else
      Function(Player)
     end
    end
   end
  end
 end)
end
return Commands

Step 3 Then add a script. Again where ever you want and paste this in it.

local function Kick(plr,reason)
 plr:Kick("Kicked For "..reason)
end

local Module = require(script.Parent.ModuleScript)

game.Players.PlayerAdded:Connect(function(plr)
 Module.AddCommand(plr,"!","kick",Kick,true)
end)

And boom your done just like that you added a kick command script in just 3 simple steps!
Now I hope you all like this script and if you do let me know by voting in the poll.

  • its good (I dont need it / already know how to make it)
  • its helpful (I will surely use it)
  • its bad (bruh it sucks)

0 voters

5 Likes

Do you know if it’s possible to have the teleport player to another player feature so that the player is teleported to another player on the same server?

yea it is possible

I appreciate the usage of my technique. Helpful tutorial!

1 Like

It is possible, however, in my opinion the commands:addcommand function is too specifically tailored for the kick command to be useful for other commands. It is calling the supplied function with the 2nd and 3rd argument typed on the command. If you make sure any function you create only uses those arguments then it could work. For a TP you would need to pass the admin player along with the player to be teleported. The whole DoReason argument and logic in the addcommand function wouldn’t make sense for a teleport.

Are you sure this works? It seems to me that this will kick the ‘admin’ who attempts to use it. Is this a joke?

   local plr2dothingwith = getplayer(plrname) 
    if plr2dothingwith then --shouldn't this be the player you are kicking that is passed to the Function
     if DoReason then
      Function(Player,reason) --Player is the 'admin' who called this function! You're gonna kick them?
     else
      Function(Player)

Am I reading this wrong? Or is this a practical joke?

wait no instead of player use plr2dothingwith

thank you and i do also appreciate your work as well i really liked how you made it abreviate (sorry 4 spell) it was really a clever trick

1 Like

I agree, the do-command argument doesn’t make sense for a teleport. I wonder if there’s a way to use the chat function to pass the admin player.

there is a way to do that i suppose

Yeah, you could do like !TP BaconHair Sir_Highness

Then, the ‘Sir_Highness’ part would end up in the variable called DoReason, then your TP function could teleport BaconHair to whataver player is in the value of DoReason. Just seems like a confusing way to do it though.

Yeah, well I would think you would test the script that you’re sharing as a Community Resource before posting it.

Would be better off to either:

  • Create an IDE with this so people can create custom commands at runtime (in-game)
Module.AddCommand(plr,"!","kick",Kick,true)
  • Remove the adding commands totally since it would be useless. If administrators cannot give custom functionality to custom commands then what’s the point of it? Just create it all in a module and index the table with the correct command, then run that pre-made function.

This poll seems 50/50, either it’s good or it’s bad.

There’s no word for “It needs improvement” or other relevant options.


Ah yes, I forgot one last thing!
Several topics like this already exist, there is no need for another one:

How To Make Admin Commands, A More In-Depth Guide: Part 1 - Resources / Community Tutorials - DevForum | Roblox

Modular Admin Commands - Resources / Community Tutorials - DevForum | Roblox

How to make chat commands using the lua chat system - Resources / Community Tutorials - DevForum | Roblox

1 Like

these are tutorials, not a direct resource

Those are also direct resources??

They give you the source code, don’t they?
You can copy that the same way you’d copy this.


You literally read, copy and paste

Isn’t that the same process for this?

So therefore it’s kind of like a tutorial isn’t it?

1 Like