API
The v2 developer API is being finalised and documented right now. Once published, existing API functions will always remain constant, so the code you write against them won't break in future updates.
Access the API from any server Script:
-- Assuming the HD Admin loader is placed in ServerScriptService
local api = require(game:GetService("ServerScriptService")["HD Admin"].Core.API)
Info
Only requestCommand is ready to use today. Everything else below is a preview of the planned surface, so signatures may change before release. If you'd like a specific function added, feel free to open an issue on our GitHub.
Server¶
requestCommand Available¶
api.requestCommand(message: string, player: Player?)
Runs a command message for you. When no player is given it runs as the server, meaning commands can fire from anywhere in your game code. When a player is given, their roles, permissions and rate limits apply exactly as if they'd typed the command in chat.
-- Run a command as the server
api.requestCommand(";fly all")
-- Or on behalf of a player
api.requestCommand(";fly me", player)
disableCommands Coming soon¶
api.disableCommands(commands: {string}, disabled: boolean?)
Disables the named commands game-wide until re-enabled, handy for commands that clash with a minigame round or a cutscene.
giveRoleAsync Coming soon¶
api.giveRoleAsync(player: Player | number, role: string, options: {scope: "perm" | "server", duration: number?}?)
Gives the role to a player. A UserId works too, so roles can be granted to players who are offline or have never joined. Permanent grants travel cross-server through the same systems as panel grants.
takeRoleAsync Coming soon¶
api.takeRoleAsync(player: Player | number, role: string)
Takes the role from a player, including permanent grants made on other servers or while they were offline.
getRolesAsync Coming soon¶
api.getRolesAsync(player: Player | number): {string}
Returns the role keys the player currently holds, most senior first.
Client¶
openMenu Coming soon¶
api.openMenu()
Opens the HD Admin panel for the local player, as if they'd pressed the topbar icon.
closeMenu Coming soon¶
api.closeMenu()
Closes the panel if it's open.
toPage Coming soon¶
api.toPage(pageId: string)
Navigates the panel to the given page, like "Commands" or "Settings", opening it first if needed.
Using v1? _G.HDAdminMain and HDAdminSetup are v1-only, so head over to Migrating from v1 when updating your game code.