s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationCodeCode BasicsCheat Sheet
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/Code
Code

Cheat Sheet

Sometimes you know what you're looking for, but you don't know where it is.

Debugging

NameCode
Logging to consoleLog.Info( $"Hello {username}" );
Drawing to screenDebugOverlay.ScreenText( new Vector2( 50, 50 ), "Hello" );
AssertingAssert.NotNull( obj, "Object was null!" )

Transforms

NameCode
Get GameObject Positionvar p = go.WorldPosition;
Set GameObject Positiongo.WorldPosition = new Vector3( 10, 0, 0 );
Get Local Positionvar p = go.LocalPosition;

GameObjects

NameCode
Find by nameScene.Directory.FindByName( "Cube" ).First();
Find by GuidScene.Directory.FindByGuid( guid );
Creatingvar go = new GameObject();
Deletinggo.Destroy()
Disablinggo.Enabled = false;
Duplicatingvar newGo = go.Clone();
Adding a Taggo.Tags.Add( "player" );
Iterate Childrenforeach( var child in go.Children )
Deleted Checkif ( go.IsValid() )

Components

NameCode
Add componentvar c = go.AddComponent<ModelRenderer>();
Remove componentc.Destroy()
Disablingc.Enabled = false;
Get GameObjectvar go = c.GameObject;
Get Componentvar c = go.GetComponent<ModelRenderer>();
Get or Addvar c = go.GetOrAddComponent<ModelRenderer>();
Iterateforeach ( var c in go.Components.GetAll() )
Deleted checkif ( c.IsValid() )
Get all activeforeach ( var c in Scene.GetAll<CameraComponent>() )

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2025-06-16. Read it rendered on the official docs.

More in Code

Advanced Topics
Api Whitelist
Code
Code Basics
Code Generation
Console Variables
Hotloading
IsValid
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.