Looking at the second piece of code I suspect it is the same problem. Here you are creating a new instance of the spawn_info which you are calling TeleportToMap(…) on, instead of referencing the instance you want to manipulate.
StartGame<public>() : void =
Print("Selecting Roles")
SelectRoles()
Print("Selecting Map")
Selection := GetRandomInt(0, 0)
Print("Teleporting the players to the Map")
var info : spawn_info = spawn_info{} # <-- Constructor creating a new instance
info.TeleportToMap(Selection) # <-- Invoking TeleportToMap on the new instance, not the one you want.
Where is the StartGame<public>():void
function located? If it is on another Verse device then what you need to do is something like this.
start_game_device := class(creative_device):
@editable
SpawnInfo:spawn_info = spawn_info{}
StartGame<public>():void =
#...
SpawnInfo.TeleportToMap(Selection)
Then from UEFN you need to
- Compile verse (Ctrl+Shift+B)
- Select your StartGameDevice in the world
- Find the SpawnInfo property in the details panel
- Select your SpawnInfo instance from the drop down