Skip to content

Command API

Everything a command can safely reference lives in CommandAPI:

local CommandAPI = require(script:FindFirstAncestor("HD Admin").Core.CommandAPI)

Loading

loadCommands Server

CommandAPI.loadCommands(details): Commands

This is what the pack modules under Config > Commands use to load, tag and modify their command sets. Open any of the packs there to see it in action.


Prompts

prompt Shared

See Server API's prompt for more details:

-- In a server command module
CommandAPI.prompt(promptType: PromptType, player: Player, text: string, options: PromptOptions?): PromptHandle

-- In a client command module
CommandAPI.prompt(promptType: PromptType, text: string, options: PromptOptions?): PromptHandle
CommandAPI.prompt("success", task.caller, "Quest complete!", {duration = 5})

Character

getHumanoid Shared

CommandAPI.getHumanoid(player: Player?): Humanoid?

The player's Humanoid, or nil if their character isn't present.


getHRP Shared

CommandAPI.getHRP(player: Player?): BasePart?

The player's HumanoidRootPart, or nil.


getHead Shared

CommandAPI.getHead(player: Player?): (BasePart?, Model?)

The player's Head and their character, or nil.


getNeck Shared

CommandAPI.getNeck(player: Player?): Motor6D?

The player's neck joint, or nil. Works for both R6 and R15 rigs.


getTorso Shared

CommandAPI.getTorso(player: Player?): Instance?

The player's torso, or nil. Works for both R6 and R15 rigs.


loadCharacter Server

CommandAPI.loadCharacter(player: Player?)

Respawns the player's character. Always use this over player:LoadCharacter() so HD Admin's tasks know the respawn was intentional.


Players

getUserInfoAsync Shared

CommandAPI.getUserInfoAsync(userId: number | string): (boolean, UserInfo | string)

Returns true and the UserInfo for any user, even offline ones, or false and a reason. Results are cached, so repeat calls are free.


getNameFromUserIdAsync Shared

CommandAPI.getNameFromUserIdAsync(userId: number | string): (boolean, string)

Returns true and the user's name, or false and a reason. Works for offline users.


teleportAsync Server

CommandAPI.teleportAsync(player: Player?, cframe: CFrame): (boolean, string)

Moves the player's character to the given CFrame, unseating them first so they don't drag their seat along.


unequipTools Server

CommandAPI.unequipTools(player: Player?): (boolean, string)

Moves the player's equipped tool back into their backpack.


Tasks

getTasks Shared

CommandAPI.getTasks(commandKey: string?, targetUserId: number?): {Task}

Returns the running tasks, optionally filtered by command and target. These are the same task objects the Task API describes.


getTasksByCallerId Shared

CommandAPI.getTasksByCallerId(callerUserId: number): {Task}

Every running task started by the given caller.


Chat

systemMessage Shared

-- In a server command module
CommandAPI.systemMessage(player: Player, text: string)

-- In a client command module
CommandAPI.systemMessage(text: string)

Sends a system-styled message into the player's chat.


forceChat Shared

-- In a server command module
CommandAPI.forceChat(player: Player, text: string)

-- In a client command module
CommandAPI.forceChat(text: string)

Makes the player say the given message.


forceBubbleChat Shared

CommandAPI.forceBubbleChat(target: Player | Model, text: string)

Shows a chat bubble above the player's character, or above any model or part you pass instead.


Outfits

getDescription Server

CommandAPI.getDescription(humanoid: Humanoid): HumanoidDescription

The humanoid's current HumanoidDescription.


applyDescription Server

CommandAPI.applyDescription(humanoid: Humanoid?, description: HumanoidDescription?, properties: {[string]: any}?): HumanoidDescription?

Applies the HumanoidDescription safely, retrying when Roblox rejects the first attempt. Pass properties to tweak fields on top of the base description.


outfitBuff Server

CommandAPI.outfitBuff(target: Player, properties: {[string]: any})

Applies HumanoidDescription properties as a buff which undoes itself when the task ends, so commands like ;wormify clean up on their own.


setFakeBodyParts Server

CommandAPI.setFakeBodyParts(character: Model, info: {[string]: any}): (() -> ())?

Swaps body parts for command-made stand-ins and returns a function that restores the originals.


clearFakeBodyParts Server

CommandAPI.clearFakeBodyParts(character: Model)

Removes those stand-ins again.


runBundleId Server

CommandAPI.runBundleId(task: Task, bundleId: number, properties: {[string]: any}?)

Dresses the task's target in a catalog bundle, restoring their own outfit when the task ends.


Assets

registerSound Shared

CommandAPI.registerSound(sound: Sound)

Required for any Sound your command creates, so the game's volume and pitch settings apply to it.


setAnchored Shared

CommandAPI.setAnchored(instance: Instance, anchored: boolean)

Anchors or unanchors every part under the instance.


setTransparency Shared

CommandAPI.setTransparency(instance: Instance, transparency: number)

Fades every part under the instance.


promptPurchaseAsync Server

CommandAPI.promptPurchaseAsync(assetId: number, player: Player?, infoType: Enum.InfoType?)

Prompts the player to purchase the asset, routing to the right purchase flow for its type.


ownsAssetAsync Server

CommandAPI.ownsAssetAsync(assetId: number, player: Player?): boolean

Whether the player owns the asset.


isTypeAsync Server

CommandAPI.isTypeAsync(assetId: number, assetType: Enum.AssetType | Enum.BundleType): (boolean, string?)

Verifies the asset is of the given type. Returns true, or false and the reason.


loadAssetCommand Server

CommandAPI.loadAssetCommand(assetType: Enum.AssetType, task: Task, assetId: number, callback: (item: Instance) -> ())

Verifies the asset is of the given type and permitted, inserts it, then hands it to your callback to place. This powers ;gear.


getToolsInfoAsync Server

CommandAPI.getToolsInfoAsync(): (boolean, {ToolInfo} | string)

Returns true and the ToolInfo of every tool available to ;give, or false and a reason.


Utility

getTargets Server

CommandAPI.getTargets(targetType: "All" | "Others" | "Nearby" | "OthersNearby", originPlayer: Player?, radius: number?): {Player}

Resolves a qualifier into the players it covers right now. "Nearby" and "OthersNearby" measure from the origin player, using radius studs (50 by default).


setCameraSubject Client

CommandAPI.setCameraSubject(newSubject: Instance)

Points the local player's camera at a new subject, like another player's Humanoid for ;view.


runPromptCommand Server

CommandAPI.runPromptCommand(promptType: PromptType, task: Task, targets: {Player}, text: string, options: PromptOptions?)

The engine behind ;message, ;hint and similar prompts. It filters the text, shows the prompt to every target, and keeps the task alive until the prompt expires.


runEmoteId Server

CommandAPI.runEmoteId(task: Task, emoteId: number, speed: number?, looped: boolean?)

Plays the emote animation on the task's target, ending it when the task ends.


createEmoteCommand Server

CommandAPI.createEmoteCommand(emoteName: string, emoteId: number, properties: {[string]: any}?): Command

Returns a complete emote command, ready to drop into your commands array. properties overrides any field on the generated command.


createBundleCommand Server

CommandAPI.createBundleCommand(commandName: string, bundleId: number, properties: {[string]: any}?): Command

The same behaviour for bundle commands like ;ratdance.


bindEmotePrompt Server

CommandAPI.bindEmotePrompt(task: Task, target: Player, emoteId: number, emoteName: string?, isLooped: boolean?)

Binds the emote action card to the task, so the target can favourite the emote or view it in the catalog.


openProfile Server

CommandAPI.openProfile(player: Player?, userId: number)

Opens the given user's profile popup for the player.


openPage Server

CommandAPI.openPage(player: Player?, pageId: string, tabLabel: string?)

Opens the player's panel straight onto the given page, optionally onto one of its tabs.


openEmotes Server

CommandAPI.openEmotes(player: Player?)

Opens the emotes popup for the player.


colourRoleName Shared

CommandAPI.colourRoleName(role): string

The role's name wrapped in its colour, for rich text.


isTableEmpty Shared

CommandAPI.isTableEmpty(tbl: {[any]: any}): boolean

Whether the table has no entries at all, including keyed ones #tbl misses.


round Shared

CommandAPI.round(number: number, decimalPlaces: number?): number

Rounds a number to the given decimal places, or to a whole number by default.


Types

Commands

type Commands = {Command}

The array a command module returns.


Command

One command table within Commands (name, args, run, and so on). Custom Commands covers every field.


Task

The task object passed into every run function, covered in full by the Task API.


ClientCommands

The client-half equivalent of Commands, returned by the Client module.


ClientCommand

One client-half command table within ClientCommands.


UserInfo

type UserInfo = {
    userId: number | string,
    userName: string,
    userImage: string,
    userDisplayName: string,
    userTopRole: {key: string, name: string, color: Color3}?,
}

userTopRole is only present for players in this server.


ToolInfo

type ToolInfo = {
    name: string,
    textureId: string,
    tool: Tool?,
}

PromptType

The prompt type strings, shared with the Server API. See prompt for the full breakdown.


PromptOptions

The options table prompt accepts, shared with the Server API.


PromptHandle

The handle prompt returns, which dismisses the prompt early with handle:Disconnect().