MBScript is the visual scripting system for the game creation tool Modbox. It was designed instead of using a existing text scripting language (like Lua/Javascript) for a few reasons:

  • To allow designers to create complex gameplay / AI with drag and drop editing (No syntax errors)
  • Can be edited with Keyboard+Mouse, in VR \ AR, with Touch on a mobile device, or with a Gamepad.
  • Designed from the start to work online. All code runs online automatically so designers never have to think about networking state
  • All changes made to MBScript code are also synced online to other players in real time - and can be edited while playing.
  • Unlike node based visual scripting (like Blueprints / Playmaker), MBScript can be switched from visual mode to text mode at any time. A integrated VSCode like text editor (Monaco) is included with Modbox.
  • Code can be copied and pasted between the node based Wiring system, which uses MBScript
  • It's event based - with events being any variable changes or ingame events on any entity in the world - so MBScript code can be easily hooked into by other scripts / mods.
  • Uses the C# type system to show the correct options and validate the drag and drop blocks

Here a MBScript asset is created to have the Entity 'Die' on Collision if the collision speed is over the 'Min Speed to Break' number variable. It also Prints the name of the Entity it collided with.

Creating Scripts

  • MBScript assets can be created with the Edit Entity Desktop Window or the Edit VR Tool. Each asset creates a new Entity Component type. MBScript Assets can be included in Entity Prefab.

  • MBScript can be edited/run at anytime (Running in edit mode can be useful for creating Editor tools / operations. Editing in play mode is a easy way to test changes.)

  • MBScript is also used to create Game Managers - which are MBScript assets that are added to the world automatically, and easily accessed by other scripts (like Singletons )

Video Tutorials


  • MBScript code runs on Events, which allows for running code based on any event happening on the Entity or in the world (such as a variable changes value, or a world event happens like a player joins).

A Event line is added for the 'Start' event - printing 'Hello World' to the screen.

A new variable 'SwitchColors' is added, with default value 'True'. Here the Entity's Color will be set a random color every Update if 'SwitchColors' is True

The 'On' lines add Event Lines to run code on events. You can then add other code line types to set values / do operations:

  • Set - Set a variable's value
  • Do - Do a method / operation / or event
  • If - Run code if a condition is true. Can then add Else lines
  • Print - Print a value to the screen, useful for quick testing
  • ForEach - Run code on a list. “Do this to everything in this set". Can run ‘ForEach Entity in the world change it’s material to Wood’
  • Wait - Wait a set amount of time before running next code
    There are a few other line types: ‘Local’ for temporary variables, Return to stop running code and return from an event, For to do a 'for' loop a set number of times, and While to keep looping while a condition is True

Code can run on multiple events and have conditions setting when it runs:


Here the first event line runs if the Entity's name changed, or if it just started.
The second event line runs when a Collision happens, and if the collision was with a Animated Humanoid

Selecting Variables

After adding a code line you use the dropdowns to choose a variable or set a value.

After selecting a variable it will show if it still needs the expected type.


The ‘If’ code line needs a ‘True/False’ value, so after selecting ‘Name’ (which is a Text variable) you still need to return a True/False value, so the ‘Select’ is shown to select an option inside the Name text.


‘Contains’ was selected to check if the name contains ‘Bob’. So if this is True the code inside the ‘If’ line will run.

The ‘+’ at the end of the line can be used to continue the line with another operation. So because ‘Contains’ returns a True/False, you can then hit the ‘+’ button and select ‘IsFalse’ to invert that return value:


The code under this “If’ line will now run if the name doesn’t contain ‘Bob’.

You can keep adding operations like this. Here the ‘Y’ part of the entity’s scale is selected, and set to the same Y value plus a random value:


Variable Options

When selecting a variable in MBScript you select from either:

  • Variables created in the Script
  • Local variables (added with Local line or as parameters to the Event)
  • Components on the Entity and their variables (like it's Name in the Main component, or Mass in the Physics component)
  • Variables in the World (like Gravity, or list of all Material Assets)
  • Or Functions - that just return a value. Like 'Func.Random.Value' or 'Func.Mathf.Cos('


Hover over a icon to see a description of the variable and it's value.


You can also hover to see the Value results at any time. Here hovering over Divide shows the value of the Health variable divided by 20


To change a variable value the Set line can be used to set to a new value (with "Set X to Y"). It can also be useful to do operations directly on the variable:


'Do' can be used to run operations on variables. Here 1 is added to the Number1 variable

The second line shows using the "Ease To" operation to change a color variable over time. This can be run just once to have it slowly turn color to black.

Lists and Queries

The 'ForEach' line can be used to iterate through lists - like the 'All Entities' list in the world.


Go through all entities in the world and print their position


Go through all Primitive components in the world and print their Material value


You can also do queries on lists (like C#'s LINQ) using 'lambda'.
Here it prints the name of all Entities with a mass greater than 1.
Could also keep adding to this, adding a 'OrderBy' to order it by mass.


  • Code lines can be dragged by moving the drag handle. Multiple lines can be selected and moved at once. Variables and values can also be dragged to copy them.
  • Right click can be used to copy and paste MBScript (which just copies it to the Clipboard as text)

Text Editing

  • MBScript can be copy and pasted as text.
  • At any time you can switch to text mode to edit, with autocomplete for variable names and immediate error updates.

Here is the same script switched to text mode and edited, checking if the Entity has a 'Primitive Component' set on it, and if it does it prints the value of the Entity's Physics Material Asset :

What’s Next