How to I get a button to send me to a random level?

I’m trying to get a system where when I press the start button on the title screen, I am randomly sent to one of 5 levels. I thought I could just use a ‘random’ node, but apparently those don’t exist in widget buttons. All help is appreciated.

First hud/widgets/gui should be only used to display data and register user clicking on widgets etc.
That is why widgets do not have all functionality.

Place your level loading event/function in something like game mode blueprint. Then detect level load button press in gui, and call event to swap levels from player controller that is owner of that widget.

So this whole thing should be done like:

  • in umg you press widget, it tells player controller that level should be changed
  • player controller calls event in game mode to change levels.

To load level you use node:

to load map as command for this node you use string “open mapname”
I do not remember if this needs path, full path or just name, you need to google this (no good results) or experiment

To load random map from list make array of strings then roll random integer in rane 1 … size of array.
and pass result as parameter to that execute console node.

This works pretty good. Create “Level Names” as a name variable set as an array. Compile. Then for the default values add each of your levels names exactly as they are spelled on the actual level name as each array element. Then create another variable called “LevelName” and set it like the screenshot. Then do some branch checks and if they are == the level name you specify then> Open Level by name and type in the level name also exactly as it’s spelled on the level and off you go. :slight_smile: