Skip to main content
Reading time: ~30 minutes
Scenes in CORP organize your game world into manageable units. They can be defined using the Roblox instance hierarchy (recommended) or programmatically via TypeScript/JSON.

Table of Contents

What are Scenes?

A scene is a container for GameObjects and represents a level, menu, or any other distinct state in your game. The recommended approach is to define scenes using Roblox Studio’s instance hierarchy, though programmatic definition is also supported.

Key Features

  • Roblox Hierarchy: Build scenes directly in Studio using Actors and Attributes (recommended)
  • Declarative Structure: Define your game world in code or JSON
  • Serialization: Save and load scenes
  • Hierarchy Support: Organize GameObjects in parent-child relationships
  • Component Configuration: Pre-configure component properties
  • Runtime Flexibility: Load scenes dynamically

Scene from Roblox Hierarchy

The primary and recommended way to create scenes is using Roblox Studio’s instance hierarchy. CORP can parse Actor instances in the workspace and convert them to GameObjects with components.

Setting Up a Scene in Studio

  1. Create Actors: Each Actor in Workspace becomes a GameObject
  2. Add Attributes: Configure component properties using Roblox attributes
  3. Use Folders: Organize your scene structure
  4. Add Components: Use ModuleScripts or StringValues to specify components

Example Studio Structure

Loading from Workspace

Or start from a specific folder:

Component Mapping in Hierarchy

Components are specified using attributes or child instances:
Note: Component names should use snake_case. Components prefixed with $ are core CORP components (e.g., $network_object).

Scene Structure

When defining scenes programmatically, they follow the SceneDescription interface:

Creating Scenes Programmatically

Basic Scene

Create a simple scene with a few GameObjects:

Scene with Hierarchy

Create GameObjects with parent-child relationships:

Scene with Transforms

Specify initial positions for GameObjects:

Scene with Network Objects

Create a scene with networked GameObjects:

Loading Scenes

Using SceneManager

The SceneManager class handles scene loading and management:

Starting with CORP

Use CORP.start() to initialize your game with a starting scene:
Or load from a path:

Scene Events

Listen for scene changes:

Scene Serialization

Exporting Scenes

Generate an Instance representation of the current scene:

Importing from JSON

Scenes can be stored as JSON and loaded at runtime:
Load the JSON scene:

Component Path Format

Component paths use the ExportPath type:
Note: ExportPath is defined as [string, string] | [string], representing either [file path, export name] or [file path] for default exports.

Configuring Components

Pass initial data to components in scenes:
The component receives these values:

Best Practices

Prefer defining scenes in Roblox Studio using the instance hierarchy. This approach provides:
  • Visual editing in Studio
  • Easier iteration and testing
  • Natural integration with Roblox’s tooling
  • Faster prototyping
Use programmatic scenes for:
  • Procedural generation
  • Dynamic content
  • Runtime scene construction

2. Organize Scenes by Purpose

Or for programmatic scenes:

2. Use Scene Hierarchy

Group related GameObjects:

3. Separate Configuration

Keep configuration separate from scene structure:

4. Choose the Right Format

For most cases, use Roblox hierarchy in Studio. Use TypeScript/JSON for:
  • Procedural content generation
  • Runtime dynamic scenes
  • Complex scripted setups
When using TypeScript for scenes:
  • Get type safety and IntelliSense
  • Enable refactoring support
  • Use import statements for organization

5. Scene Transitions

Handle scene transitions gracefully:

6. Dynamic Scene Loading

Load scenes based on game state:

Common Patterns

Procedural Scene Generation

Generate scenes programmatically:

Scene Prefabs

Create reusable GameObject descriptions:

Next Steps


Master scene management to organize your game world effectively! 🎬