I am currently working on making an admin panel for me to use in my games, but I wanted me or other users to be able to create their own commands to use easily, but it is quite weird at the moment, and would like to know if anyone has any better ideas on how to do this.
This is how it currently works:
You give a table in the main script, which tells the game what the command should be labeled as in the menu and what the module script is called that it runs
commands = {
{Title = 'Shut Down Server',Command = "ShutDownServer"},
{Title = 'Kill All Players',Command = "KillAllPlayers"},
{Title = 'Teleport All To Me',Command = "TeleportAllPlayers"},
}
It then calls a remote event, which checks if the player is an admin, and then calls the relative module script
game.ReplicatedStorage.AdminPanel.RemoteEvent.OnServerEvent:Connect(function(plr, command)
local IsAdmin = CheckIfAdmin(plr)
if IsAdmin then
local command = game.ServerScriptService.AdminPanel:WaitForChild(command)
require(command).run()
else
plr:Kick("Hacking is against roblox ToS, stop it")
end
end)
But this can be really finicky to use, because the player has to define the script, then create the script in the replicated storage area, and then create function called something like Module.run()
and then define the function under that.
Is there a better way of me doing this that would make it easier for people to create the functions that they want to run?