✓ Accepted answer
Hey!
Admin command systems are pretty easy to make. The only real "challenging" part (for some people) is the string manipulation. While it isn't difficult, it's just hard for some to wrap their heads around. Once you have your head wrapped around it, it becomes quite easy and you can make your argument handler as advanced as you really want it to be. For example, if you wanted, you could make it so that you predefine your arguments and automatically parse them to a player, string, int, etc... It really just depends on your programming knowledge and use case. Below is an example from the command table in a command handler I made a few months ago.
Click to view
Lucky for you though, I actually helped somebody else out with getting started on their own little admin command system a few days ago and quickly wrote up a VERY simple framework to start working off of. Mind, this is a super simple system and I don't really recommend it for large scale use due to its simplicity.
local prefix = "!"
local Commands = {
["fov"] = function(args)
workspace.CurrentCamera.FieldOfView = tonumber(args[1])
end
}
game.Players.PlayerAdded:Connect (function(plr)
plr.Chatted:Connect (function(msg)
local args = string.split(msg, " ")
local cmd = args[1]
if cmd:sub(1,#prefix) == prefix then
cmd = cmd:sub(#prefix + 1, #cmd)
if Commands[cmd:lower()] then
table.remove(args, 1)
Commands[cmd:lower()](args)
end
end
end)
end)
I hope this helped you out a bunch and if this did help you, please remember to upvote and accept the answer.
4 comments
local prefix = "!" local Commands = { ["fov"] = function(args) workspace.CurrentCamera.FieldOfView = tonumber(args[1]) end } game.Players.PlayerAdded:Connect (function(plr) plr.Chatted:Connect (function(msg) local args = string.split(msg, " ") -- this will separate the string into an array ("hey there" -> {"hey", "there"}) local cmd = args[1] -- first argument
Hi! Thank you for the response, but for my purpose I'm actually using it as an exploit through Synapse X. Was I supposed to change a value or anything? No errors are shown in console however it doesn't seem to be working.
Yep. If you’re trying to use this with something like Synapse, get rid of the PlayerAdded event and make a reference (a variable) to the client (game.Players.LocalPlayer) and call it “plr”.
ew text commands