WorldSelectScriptPackage - Switch between lobby and level worlds with ease


What is it?

A package to help users (particularly those who don’t want to write code) to create games where there are multiple worlds, especially where those worlds are used as levels within the game.

This was inspired by a request from SevenDos - I’m sure there are other similar packages but I wrote most of this from scratch with some inspiration from Andy’s world tutorial and Cereal’s saveData package code.

Yeah… but what is it?

The package consists of one ScriptFolder containing a single script (currently) designed to be deployed as a child of the User entity.

How to I deploy it?

Go to the community tab on the left hand panel and search for WorldSelectScript. Select the User entity in the right hand panel (click on the dropdown that shows World and select User instead). Go to packages at the bottom on the left panel and drag the User_WorldSelectScriptFolder to your User Entity so it appears as a child script folder.

How do I use it?

  • First - set the properties according to how you want your worlds to work (see table below). You do this by going to the Script Folder under User in the right hand panel of the editor. You’ll see the properties under the WorldSelectScript.
  • Once you have the properties set, are two key functions within the script that should be useful:
    • MoveToNextWorld - call this via an event. This could be called by a Trigger (e.g. onTriggerEnter) or via an event called by the GameScript if you are using that script / package. This will only affect the current user / character and so usually makes more sense for a trigger.
    • MoveAllUsersToNextWorld - call this via an event. Bear in mind that if any event calls this then it will affect all players so might not be what you want for a trigger. Also be cautious using this with ‘Jump To Saved World’ as if a user joins and they are in the wrong world then this will change the world for everyone.

Can I see it ‘in action’

I’ve created some very basic examples here:

  • Random Switching Example: [Crayta]
  • Ordered Example: [Crayta] - switching based on a list that goes [1,2,3,2]


Name Type Default Description
World List WorldAsset Array [nil] Drag and drop worlds from the left hand panel to this list (or start typing the names)
Has Lobby World Boolean false If there is a dedicate lobby world you want to start in / return to between levels
Lobby WorldAsset nil Drag and drop your lobby world here from the left hand panel or type the name
Return To Lobby World Boolean false Set to true if you want to return to the lobby between each level world (e.g. L1 - Lobby - L2 - Lobby - etc.)
Order number (options) 1 1 = ordered(run through the order they appear in the WorldAsset array, 2 = random (picked at randome from WorldAsset), 3 = ordered based on a numbered list in the next property
Specific Order number array [nil] add numbers to the array representing the items in the WorldAsset Array list (e.g. if you have three items in the World List Array then add 3, 2, and 1 to visit the array list in reverse order)
Wait Before Switch boolean false If true then there will be a pause between switching worlds
Amount To Wait Before Switch number 0.5 Amount of time to wait between switching
Persist Saved Data boolean false If enabled then saved data will not be deleted when you emerge in the new world. This could be useful if you want to have users return to the most recent stage they were at in level progression.
Jump To Saved World boolean false If enabled then the user will jump to the world that appears in their saved data even if they spawn in a different world initially. Not recommended in combination with having all users switch worlds at once. Note In preview mode this made cause repetitive calls as preview mode will not actually switch worlds
Debug Mode boolean false If enabled there will be verbose output to the console window - useful for tracking down issues / unexpected behaviour in preview mode. This won’t do anything once published
Save Data Version number 1.0 (at time of writing) For future in case the saved data changes schema

Save Data

Each time the world switch occurs the following is saved:

  • Version Number of the save data - from the property above
  • isLobbyWorld - are we moving to a ‘lobby world’ - as specified in property above
  • currentWorld - which world (in the WorldList array) are we moving to. e.g. 1 = first world in the list
  • posOrderArray - where are we in the ‘Specific Order’ Array. e.g. if the Specific Order is [3, 2, 1, 2] and posOrderArray is 4 then that means we are moving to World 2 (the second World from the WorldList array)

Other Info

Any cool stuff I can do?

You have the option of having users alternate between levels and lobbies. Those levels can be in a specific order or can be random. You can also use the ‘Jump To Saved World’ setting to remember what world level a player was on even if (e.g.) the game crashes and returns to the lobby during the loading phase.

Future plans?

I’ll happily take requests / bug reports to let me know what would be useful in future. I did think about having messages before / after the world change (maybe via a widget?). I have tried to test a few different combinations of the properties but it is impossible to test all iterations and also testing world switching preview mode isn’t possible (which has made things super painful to debug!)