# UEFN VERSE - Add props to an array to trigger a dispose() and remove them when the player is closed to it.

**URL:** <https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [September 19, 2025, 2:21pm UTC](https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236 "2025-09-19T14:21:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobbySixKillah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bobbysixkillah/32/875404_2.png) [@BobbySixKillah](https://forums.unrealengine.com/u/BobbySixKillah)\
**Post date:** [September 19, 2025, 2:21pm UTC](https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236/1 "2025-09-19T14:21:05Z")

</div>

> ```auto
> 
> using { /Fortnite.com/Devices }
> using { /Verse.org/Native }
> using { /Fortnite.com/Characters }
> using { /Verse.org/Random }
> using { /Verse.org/Simulation }
> using { /UnrealEngine.com/Temporary/Diagnostics }
> using { /UnrealEngine.com/Temporary/SpatialMath }
> using { /Fortnite.com/Playspaces }
> 
> CollectibleSystem := class(creative_device):
> 
> @editable
> creatureSpawner : creature_spawner_device = creature_spawner_device{}
> 
> # Reference to a creative_prop_asset array
> @editable
> var CoinsProp:[]creative_prop_asset := array{}
> 
> # A map to store references to the spawned props.
> var SpawnedCoinsProps:[]creative_prop = array{}
> 
> OnBegin<override>()<suspends>:void=
> 
> creatureSpawner.EliminatedEvent.Subscribe(OnCreatureEliminated)
> 
> Playspace : fort_playspace = GetPlayspace()
> AllPlayers := Playspace.GetPlayers()
> 
> Print("About to LOOP " )
> 
> if (FirstPlayer := AllPlayers[0]):
> if (FortniteCharacter :fort_character = FirstPlayer.GetFortCharacter[]):
>                   
> loop:
> 
> Sleep(1.0)
> Print("ENTER THE LOOP " )
> 
> PlayerPosition := FortniteCharacter.GetTransform().Translation
>               
> for ( Prop : SpawnedCoinsProps):
> Proppos:=Prop.GetTransform().Translation
> thedistance:=Distance(PlayerPosition,Proppos)
> Print("Your distance prop is: " + ToString(thedistance))
> if(thedistance <= 150.0):   
> Prop.Hide()  
> Prop.Dispose()
>                       
> OnCreatureEliminated(DeviceAIInteractionResult: device_ai_interaction_result):void=
> if (TargetAgent := DeviceAIInteractionResult.Target?, TargetFortCharacter:=TargetAgent.GetFortCharacter[]):
>      
> spawnPos := TargetFortCharacter.GetTransform().Translation
> 
> if:
> PropToSpawn := CoinsProp[0] # Use the first prop in the array for now
> SpawnedProp := SpawnProp(PropToSpawn, spawnPos, IdentityRotation())
>   
> 
> if (SourceAgent := DeviceAIInteractionResult.Source?, FortCharacter:=SourceAgent.GetFortCharacter[]):
> var PlayerLocation : vector3 = FortCharacter.GetTransform().Translation
> 
> distance:=Distance(spawnPos,PlayerLocation)
>        
> 
> ```

I’m trying to get an array of props spawned when Ennemies are elimated ( SpawnedCoinsProps)  
to check in a loop if Player is closed enough to one of them to dispose the actual prop ( remove from the scene to add +1 coins in a gauge)

My problem :

I ‘m not succeeding in filling this array when the props are spawned.  
I tryed different syntaxes and method but I’m struggling to find how to fix this little puzzle.

---

<div class="post-metadata">

**Author:** ![Flak](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/flak/32/769441_2.png) [@Flak](https://forums.unrealengine.com/u/Flak)\
**Post date:** [September 25, 2025, 12:26pm UTC](https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236/2 "2025-09-25T12:26:41Z")

</div>

I’ll see if I can find someone to help.

---

<div class="post-metadata">

**Author:** ![Vath](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vath/32/752388_2.png) [@Vath](https://forums.unrealengine.com/u/Vath)\
**Post date:** [September 25, 2025, 1:25pm UTC](https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236/3 "2025-09-25T13:25:58Z")

</div>

Hi @BobbySixKillah

> I ‘m not succeeding in filling this array when the props are spawned.

Looking at your script here, I see that you’re not adding to your SpawnedCoinProps array or ensuring that you grab the prop safely.

In OnCreatureEliminated, after you grab the first prop and spawn it. You’ll also want to ensure it’s spawned and unwrap the returned creative\_prop

```verse
            # Properly handle SpawnProp return tuple
        if (PropToSpawn := CoinsProp[0]):
            SpawnResult := SpawnProp(PropToSpawn, SpawnPos, IdentityRotation())
            if (SpawnedProp := SpawnResult(0)?):
                if (SpawnResult(1) = spawn_prop_result.Ok):

```

From there you can add it to the array:

```verse
	            # Properly handle SpawnProp return tuple
            if (PropToSpawn := CoinsProp[0]):
                SpawnResult := SpawnProp(PropToSpawn, SpawnPos, IdentityRotation())
                if (SpawnedProp := SpawnResult(0)?):
                    if (SpawnResult(1) = spawn_prop_result.Ok):
                        # Add spawned prop to array
                        set SpawnedCoinsProps += array{SpawnedProp}

```

Let me know if this helps your problem

---

<div class="post-metadata">

**Author:** ![BobbySixKillah](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bobbysixkillah/32/875404_2.png) [@BobbySixKillah](https://forums.unrealengine.com/u/BobbySixKillah)\
**Post date:** [September 29, 2025, 10:54am UTC](https://forums.unrealengine.com/t/uefn-verse-add-props-to-an-array-to-trigger-a-dispose-and-remove-them-when-the-player-is-closed-to-it/2658236/4 "2025-09-29T10:54:24Z")

</div>

Yes it works now,  
I wasn’t clear on how to question this prop added and the syntax to add the prop object to the array in the “if (SpawnResult(1) = spawn\_prop\_result.Ok)”

Thanks for your help!
