# Set tags on objects spawned with Verse

**URL:** <https://forums.unrealengine.com/t/set-tags-on-objects-spawned-with-verse/1422980>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [November 26, 2023, 3:26pm UTC](https://forums.unrealengine.com/t/set-tags-on-objects-spawned-with-verse/1422980 "2023-11-26T15:26:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Happyllama25](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Happyllama25](https://forums.unrealengine.com/u/Happyllama25)\
**Post date:** [November 26, 2023, 3:26pm UTC](https://forums.unrealengine.com/t/set-tags-on-objects-spawned-with-verse/1422980/1 "2023-11-26T15:26:51Z")

</div>

Hi there. When using the direct tag examples from [the docs](https://forums.unrealengine.com/t/instantiating-a-struct-in-verse/821142/12) I get the following errors: `Data definitions at file scope must specify their value domain. (3547)` and `Module-scoped 'var' 'weak_map' type must have 'session' key type. (3502)`

Relevant code is below, I eventually want to get all objects with those tags, randomly pair and teleport them together, then remove the indexed item from the array, and loop. This means the array needs to be a `var` as it needs to be changed (have items removed), right?

New to Verse, a tad confused about this one…

```auto
using { /Fortnite.com/Devices }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags}
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
room_entrance_tags := class(tag) {}
room_exit_tags := class(tag) {}
var Room_Entrances := GetCreativeObjectsWithTag(room_entrance_tags{})
var Room_Exits := GetCreativeObjectsWithTag(room_exit_tags{})
# AllCreativeObjects : []creative_object_interface := GetCreativeObjectsWithTag(room_entrance_tags{}) # From the docs example, not used, but still errors.

```

Something sort of along the lines of

```auto
RandomiseRooms()<suspends> : void=
    for (Exit := Room_Exits):
        Index := Random(0, room_entrances.length)
        SelectedEntrance = room_entrances[Index]
        SelectedEntrance.TeleportTo(Exit)
        # Remove the already chosen exit from the array
        if (Removed_Exit := Room_Exits.RemoveElement[Exit.Index]): # Does array.Index exist?
            set Room_Exits = Removed_Exit
            # And the entrance too
            if (Removed_Entrance := Room_Entrances.RemoveElement[Index]):
                set Room_Exits = Removed_Exit
                return

```

If this is the wrong way to pursue this idea, please point me in the direction of alternatives, or if I should split this post into two separate questions/topics, thanks!

---

<div class="post-metadata">

**Author:** ![bananna\_manuk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bananna\_manuk](https://forums.unrealengine.com/u/bananna_manuk)\
**Post date:** [November 27, 2023, 6:14pm UTC](https://forums.unrealengine.com/t/set-tags-on-objects-spawned-with-verse/1422980/2 "2023-11-27T18:14:19Z")

</div>

you have to store the all the exits execpt the chosen exit into a temp array  
then overwrite your original array with the temp array

don’t ask me why, i read you do it this way somewhere and it works for me

---

<div class="post-metadata">

**Author:** ![Happyllama25](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Happyllama25](https://forums.unrealengine.com/u/Happyllama25)\
**Post date:** [November 28, 2023, 6:30am UTC](https://forums.unrealengine.com/t/set-tags-on-objects-spawned-with-verse/1422980/3 "2023-11-28T06:30:52Z")

</div>

Oh wow, alright, I’ll try that out.
