How to code a good admin system?

  1. What do you want to achieve?
    I want to make a simple but good admin with modules mostly for moderation and some other commands. One of these types of admins that uses module scripts.

  2. What is the issue?
    I just know how to do the tradicional/simple one: Just a single script on ServerScriptService maybe with 1 or 2 module scripts that detects admins and connects them to :Chatted() The problem of this one is that if you want a lot of commands you have to use elseif a lot of times.

  3. What solutions have you tried so far?
    I saw some posts about this but every post i saw has the same admin: The tradicional one.

I was trying to make an admin, I made the configuration, the commands, but then I didn’t know how to detect ranks and chat and my tries just didn’t work.

So, How would I make an admin? What do I have to do? What knowledge do I require?

(I don’t want scripts, maybe only small examples)

Any help is appreciated :slight_smile:

Making your own custom Admin script can be complicated, depending on the situation and what you want to do. Although, all you need to do is this:

Make a module script for each command and place every module script into a folder. Each module script could have basic contents such as:

local module = {}

function module.run(playerWhoChatted, argument1, argument2) -- Do stuff under here.

end
	
return module

Each module would have the same .run() function for practical reasons.

Detect the command they’re running, and separate the arguments they added by spaces. You can use :split() to convert them to a table. You might need to use RegEx to understand the code.

local commandName = text:match("^"..prefix.."(%S+)")
local arguments = text:match("^"..prefix.."%S+%s+(.+)")
arguments = arguments:split("%s") -- Split the arguments by spaces.

Require the module script and put in the player who said the message and the arguments said. Add a guard clause to check if the command they said exists.

local command = commandsFolder:FindFirstChild(commandName)
if not command then return end
local moduleToRun = require(command)
moduleToRun.run(playerWhoChatted, table.unpack(arguments))

You could use datastores to store ranks or make a hard-coded list in your admin script.

1 Like

Thanks for your reply, it’s really helpful and I will try to do it.
I have a question, how would you run commands on client-side? Like make a part appear only on client when a command runs. Or open a GUI on client-side instead of server-side.

1 Like

You could use RemoteEvents to send data to the client, and the client will handle those requests.

1 Like

You inspired me to create a tutorial on this exact question!

If you’d like a detailed look into how to create a detailed admin system,

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.