How to make a admin script?

Hey! I was wondering how to make admin script. When i tried to look at other admins scripts, there is no script! Are they magicians? Hackers? The world may never know!?

If I try and search it up on youtube, I see a bunch of exploit videos. So, the question remains, how do I make an admin script, and where does the scripts go!? (they aren’t in the model…)

5 Likes

They use modules, to find the source for the script, do CTRL + F and search for require, you will see something that looks like this - “require(4354324)”, grab the number that is in the parentheses
and put it in this link - https://www.roblox.com/library/insertnumberhere/ , some will be close sourced, and some will be open-sourced, as for making an admin script, if you don’t have a lot of experience in LUA, I wouldn’t tackle a project of this scale, start small with some tutorials, etc.

4 Likes

Closed Source No Longer Works


I think the only available sources are open-sourced. Removing Support for Third Party Closed Source Modules changed the game. If the modules doesn’t work, it’s because the scripts are not open-sourced.

Apparently they stated that closed source can contain malicious code, if the developer cannot audit its contents.

4 Likes

Since this change in February, the modus operandi of bad actors wishing to get their malware into your game has become uploading the bad code modules via disposable alts, and hiding the require(moduleId) statements in the module through some combination of obfuscation and needle-in-haystack techniques. It’s great that private modules are no longer allowed in free models, but you still need to carefully audit anything you add to your game. If it looks at all dodgy, chances are better than even that it is.

Since the crackdown on botting free models to the top of searches, I’ve also personally noticed a sharp increase in number of “developers” reaching out to me through third-party chat and IM services to offer their free scripting assistance or anti-exploit solutions. Obviously, you should not give team create access to, or use models/plugins from someone eager to work on your game for free!

TLDR; Write your own admin scripts using remote events or chat commands and robust server-side userid authentication of the person issuing the command.

7 Likes

There are several ways to make an admin script. You can always reference open source MainModules for admin scripts (i.e. Adonis, Basic Admin Essentials) or search for certain items yourself. Sometimes, you won’t even need an admin script. You can integrate any of that functionality into a panel with specialised access.

I find that admin scripts only have any real use in debugging or roleplay-ish groups. I’ve almost never seen an actual production game use an admin script.

2 Likes

This is why I don’t really recommend learning from big admin scripts, as they can often be confusing, very broad, and some outdated.

In order to make an admin script, you need to create a server script, place it preferably in ServerScriptService, and then make it listen for chat messages. If it finds a message that starts with your desired prefix (such as ":"), check if it’s a valid command, if the player is an admin, etc.
What you should not do is using if statements along with string.sub to check for commands and arguments. Instead, store all commands as functions in a table, and upon finding a chatted command split the message by spaces, match the first split against the list of commands, and call the command function with the rest of the arguments.

Example code:

local admims = {ScytheSlayin = true}
local plrs = game:GetService"Players"
local cmds = {} --make commands an empty table, it's gonna be a dictionary table

local prefix = ";"

local function AddCommand(name, func) --addcommand function, for adding commands
    cmds[name:lower()] = func --insert the command into the table, the name of it will be the key
end

local function Split(str)
    local words = {}
    for str in string.gmatch(str, "([^%s]+)") do --split by space
        words[#words + 1] = str --insert all splitted words into the table
    end
    return words
end

local function GetPlayers(text, plr)
    local t = {}
    if text = "all" then --if text is "all", return all players
        return plrs:GetPlayers()
    elseif text == "me" then --if it's "me", return a table with only the plr
        return {plr}
    elseif text == "others" then --if it's "others", return everyone except the plr
        for i,v in pairs(plrs:GetPlayers()) do
            if v ~= plr then
                table.insert(t, v)
            end
        end
        return t
    end
    --if none from above, loop through all players
    for i,v in pairs(plrs:GetPlayers()) do
        if v.Name:lower():sub(1,#text) == text:lower() then --if first x characters of their nickname match the text
            table.insert(t, v) --add them to the table
        end
    end
    return t
end

AddCommand("kill", function(plr, args)
    if not args[1] then return end --exit if no args were supplied
    for i,v in pairs(GetPlayers(args[1], plr)) do
        if v.Character then
            v.Character:BreakJoints()
        end
    end
end)

plrs.PlayerAdded:Connect(function(plr)
    if admins[plr.Name] then
        plr.Chatted:Connect(function(msg)
            if msg:sub(1, #prefix) == prefix then --if starts with the prefix
                msg = msg:sub(#prefix + 1) --remove the prefix
                local args = Split(msg)
                local cmd = cmds[table.remove(args,1):lower()]
                if not cmd then return end --command not found
                pcall(cmd, plr, args) --run the command
            end
        end)
    end
end)

(forgive any mistakes, it’ 1:35 am and I’m on mobile)

8 Likes

I recommend using Person299’s admin script as a starter for reference, then work from there up. The script’s over a decade old, but it appears to hold up fairly well, aside from deprecated methods.

2 Likes

Server scripts should be put in ServerScriptService as they will not execute in ServerStorage, to quote the Wiki:

Scripts will not run when they are parented to ServerStorage, although ModuleScripts contained within can be accessed and ran. It is recommended developers use ServerScriptService to hold Scripts they wish the server to execute.

7 Likes

My bad, I meant ServerScriptService.
I guess scripting at 1am wasn’t a good idea

3 Likes

If you’re going to make a admin script like Kohls admin, beware of a backdoor.

3 Likes

There’s a great video on this very topic by @Spooks_HD.

Watch it here.

Note: this covers the bare bones of admin systems. I am assuming you know the bare bones of Lua programming.

I recommend trying to make your own admin, as you get to implement whatever commands you want, and you understand the contents of your programming. Plus, it removes the hassle of the issue presented in the OP.

3 Likes