Skip to main content
Reading time: ~40 minutes (reference material)
Complete API documentation for CORP (Component-Oriented Replicated Programming).

Table of Contents


Core Classes

CORP

Main entry point for the framework.

Methods

CORP.start(configuration: Configurations.GameConfiguration): void
Starts CORP with a configuration object.
Parameters:
  • configuration.startingScene - Scene description or path to scene
CORP.startFromWorkspace(): void
Starts CORP using existing workspace instances (for rapid prototyping).

GameObject

Represents an entity in the game world. Container for Components.

Constructor

Parameters:
  • name - Name of the GameObject

Properties

Methods

addComponent<T>(clazz: Constructable<T>, config?: ComponentConfig<T>): T
Adds a component to the GameObject.
Parameters:
  • clazz - Component class to add
  • config - Optional configuration object
Returns: The added component instance
getComponent<T>(clazz: Constructable<T> | string): T | undefined
Gets a component from the GameObject.
Parameters:
  • clazz - Component class or path string
Returns: Component instance or undefined
hasComponent<T>(clazz: Constructable<T>): boolean
Checks if GameObject has a component.
Parameters:
  • clazz - Component class to check
Returns: True if component exists
removeComponent<T>(clazz: Constructable<T>): void
Removes a component from the GameObject.
Parameters:
  • clazz - Component class to remove
destroy(): void
Destroys the GameObject and all its components.
setParent(parent: GameObject | Scene | undefined): void
Sets the parent of this GameObject.
Parameters:
  • parent - New parent GameObject, Scene, or undefined
getParent(): GameObject | Scene | undefined
Gets the parent of this GameObject.
Returns: Parent GameObject, Scene, or undefined
getChildren(): GameObject[]
Gets all child GameObjects.
Returns: Array of child GameObjects
getDescendants(): GameObject[]
Gets all descendant GameObjects recursively.
Returns: Array of all descendant GameObjects
getTransform(): CFrame
Gets the transform (position and rotation) of the GameObject.
Returns: CFrame representing the transform
setTransform(transform: CFrame): void
Sets the transform of the GameObject.
Parameters:
  • transform - New CFrame transform
getPosition(): Vector3
Gets the position of the GameObject.
Returns: Vector3 position
getName(): string
Gets the name of the GameObject.
Returns: GameObject name
getInstance(): Actor
Gets the underlying Roblox Instance.
Returns: Actor instance

Static Methods

GameObject.fromInstance(instance: Actor, name: string): GameObject
Creates a GameObject from an existing Roblox Instance.
Parameters:
  • instance - Roblox Actor instance
  • name - Name for the GameObject
Returns: New GameObject
GameObject.importGameObject(description: GameObjectDescription, parent: GameObject | Scene, isClient: boolean): GameObject
Imports a GameObject from a scene description.

Component

Abstract base class for all components.

Constructor

Parameters:
  • gameObject - GameObject this component is attached to
  • initOnCreated - Whether to initialize immediately (default: true)

Properties

Methods

abstract onStart(): void
Called when the component starts. Must be implemented.
abstract willRemove(): void
Called before the component is removed. Must be implemented.
abstract getSourceScript(): LuaSourceContainer
Returns the script that defines this component. Must be implemented.
willStart(): void
Called before onStart. Override for pre-initialization.
onPropertiesApplied(): void
Called after properties are applied via serialization. Override to react to configuration.
initialize(): void
Initializes the component. Called internally by CORP.
remove(): void
Removes and destroys this component.
getGameObject(): GameObject
Gets the GameObject this component is attached to.
Returns: GameObject instance
Component Shortcuts
These methods are shortcuts to GameObject methods:

Behavior

Extends Component with serialization support. Use this as the base for most components.

All Component Methods

Behavior inherits all methods from Component.

Methods

serializeState(): Partial<Behavior>
Returns the serialized state of all @SerializeField properties.
Returns: Object containing serialized field values

Properties


Networking Classes

NetworkObject

Makes a GameObject replicate across the network.

Constructor

Properties

Methods

spawn(): void
Spawns the NetworkObject on the network (server only).
changeOwnership(owner: Player | undefined): void (Server Only)
Changes the owner of this NetworkObject.
Parameters:
  • owner - New owner Player, or undefined for server
getOwner(): Player | undefined
Gets the current owner.
Returns: Owner Player or undefined (server owned)
getId(): string
Gets the unique network ID.
Returns: Network ID string

NetworkBehavior

Network-replicated component. Requires NetworkObject.

Constructor

All Behavior Methods

NetworkBehavior inherits all methods from Behavior.

Methods

getNetworkObject(): NetworkObject
Gets the associated NetworkObject.
Returns: NetworkObject component
getId(): string
Gets the unique network behavior ID.
Returns: Network behavior ID

NetworkedVariable

Replicated variable that synchronizes between server and clients.

Constructor

Parameters:
  • initialValue - Initial value
  • config - Configuration options
Config Options:

Properties

Methods

getValue(): T
Gets the current value.
Returns: Current value
setValue(value: T): void (Server Only)
Sets the value (server only).
Parameters:
  • value - New value

NetworkedList

Replicated list/array.

Constructor

Properties

Methods

push(item: T): void (Server Only)
Adds an item to the end.
remove(index: number): T | undefined (Server Only)
Removes an item at index.
get(index: number): T | undefined
Gets an item at index.
set(index: number, value: T): void (Server Only)
Sets an item at index.
size(): number
Gets the size of the list.

NetworkedMap

Replicated map/dictionary.

Constructor

Properties

Methods

set(key: K, value: V): void (Server Only)
Sets a key-value pair.
get(key: K): V | undefined
Gets a value by key.
delete(key: K): boolean (Server Only)
Deletes a key.
has(key: K): boolean
Checks if key exists.

NetworkedSet

Replicated set.

Constructor

Properties

Methods

add(item: T): void (Server Only)
Adds an item to the set.
delete(item: T): boolean (Server Only)
Deletes an item from the set.
has(item: T): boolean
Checks if item exists in set.

RPC

Namespace for RPC decorator and configuration.

Decorator

@RPC.Method(config: RPC.Config)
Marks a method as a Remote Procedure Call.

Configuration

Enums

RPC.Endpoint
  • CLIENT_TO_SERVER - Client calls server
  • SERVER_TO_CLIENT - Server calls client
  • CLIENT_TO_CLIENT - Client calls client (not yet implemented)
  • CLIENT_LOCALLY - Client calls locally
  • SERVER_LOCALLY - Server calls locally
RPC.AccessPolicy
  • NONE / ANYONE - Anyone can call
  • OWNER - Only owner can call
  • NOT_OWNER - Only non-owners can call
RPC.ReturnMode
  • DOES_NOT_RETURN / VOID - No return value
  • RETURNS - Returns a value
RPC.Reliability
  • RELIABLE - Guaranteed delivery
  • UNRELIABLE - Fast but may be dropped

Scene Management

SceneManager

Manages game scenes.

Properties

Methods

static loadScene(scene: SceneSerialization.SceneDescription): Scene
Loads a scene.
Parameters:
  • scene - Scene description
Returns: Loaded Scene instance
static unloadScene(): void
Unloads the current scene.
static changeScene(scene: SceneSerialization.SceneDescription): void
Changes to a new scene (unloads current, loads new).
Parameters:
  • scene - Scene description
static importScene(scene: SceneSerialization.SceneDescription): Scene
Imports a scene from description without loading.
Returns: Scene instance

Scene

Represents a game scene.

Properties

Methods

startFromWorkspace(): void
Starts the scene from existing workspace instances.

Utilities

Signal

Event system for type-safe callbacks.

Constructor

Parameters:
  • name - Optional name for debugging

Methods

connect(callback: (...args: T) => void): Connection<T>
Connects a callback to the signal.
Parameters:
  • callback - Function to call when signal fires
Returns: Connection object
fire(...args: T): void
Fires the signal with arguments.
Parameters:
  • ...args - Arguments to pass to callbacks
destroy(): void
Destroys the signal and disconnects all connections.

Collector

Garbage collector for automatic resource cleanup.

Methods

add(item: RBXScriptConnection | Instance | (() => void) | { destroy(): void }): void
Adds an item to be cleaned up.
Parameters:
  • item - Connection, Instance, function, or object with destroy method
teardown(): void
Cleans up all added items.

Type Definitions

SceneSerialization.SceneDescription

SceneSerialization.GameObjectDescription

SceneSerialization.ComponentDescription

Configurations.GameConfiguration


Next Steps


Complete API reference for building games with CORP! 📚