Skip to main content
Reading time: ~20 minutes
Macros in CORP are powerful tools for transforming instance hierarchies during scene loading. They allow you to programmatically modify, replace, or generate Roblox instances based on tagged markers in your workspace or scene data.

Table of Contents

What are Macros?

Macros are classes that extend Macro and implement a transformInstanceHierarchy() method. When CORP encounters an instance tagged with a macro name, it invokes that macro to transform the instance hierarchy.

Key Features

  • Instance Transformation: Modify or replace instances during loading
  • Procedural Generation: Generate complex hierarchies from simple markers
  • Template Expansion: Convert placeholder instances into full structures
  • Dynamic Configuration: Create instances based on game state or data

How Macros Work

  1. You create instances in Workspace or scenes
  2. Tag them with a macro name (e.g., %spawn_point_macro)
  3. During loading, CORP applies the macro transformation
  4. The macro returns the transformed instance hierarchy

Creating a Macro

Basic Macro Class

Macro with Configuration

Read attributes from the tagged instance:

Complex Macro with Children

Process child instances and generate complex structures:

Using Macros

Tagging Instances in Studio

  1. Create an instance (Part, Model, Folder, etc.)
  2. Add a tag using the Tag Editor plugin
  3. Use the format %macro_name (e.g., %spawn_point_macro)

Programmatic Application

Macros are automatically applied when loading from workspace:
Or apply macros manually to an instance tree:

Getting Macro Information

Macro Registration

Macros must be registered in your Gamepack’s exports to be available.

Registering in Gamepack

Create exports/macros.ts:
Naming Convention: Always use snake_case for macro mapping names. This ensures consistency across your codebase and makes tags easy to read.

Common Use Cases

1. Spawn Point Generation

2. Prefab Instantiation

3. Procedural Environment

4. Dynamic Layout

Best Practices

1. Use snake_case for Names

2. Clean Up Original Instances

Always destroy the original instance after transformation:

3. Handle Edge Cases

4. Use Attributes for Configuration

5. Preserve Hierarchy

Maintain parent relationships when transforming:

6. Document Your Macros

Next Steps


Master macros for powerful procedural generation and instance transformation! 🔧