# Why doesn't it give the objects to the selected "Player"...v

**URL:** <https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player-v/1982661>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [August 19, 2024, 9:50am UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player-v/1982661 "2024-08-19T09:50:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fali](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fali/32/1072003_2.png) [@Fali](https://forums.unrealengine.com/u/Fali)\
**Post date:** [August 19, 2024, 9:50am UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player-v/1982661/1 "2024-08-19T09:50:50Z")

</div>

Why doesn’t it give the objects to the selected “Player”…

I’ve been trying to make the code for a few days now to select the murderer, the sheriff and the innocents.

The murderer gets his gun, but the second player never gets anything.

What is the problem I have???

```auto
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Verse.org/Assets }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }

SeleccionRol := class(creative_device):

    var PlayerMap : [player]SeleccionAsesino = map{}

    @editable var MinimoAleatorio : int = 0
    @editable var MaximoAleatorio : int = 0

    var NumeroAleatorioJugadores : []int = array{}

    var IndicadorJugadorMurder : int = -1
    var IndicadorJugadorSheriff : int = -1

    @editable ItemGranterAsesino : item_granter_device = item_granter_device{}
    @editable ItemGranterSheriff : item_granter_device = item_granter_device{}
    @editable ItemGranterInocente : item_granter_device = item_granter_device{}

    @editable TriggerActivador : trigger_device = trigger_device{}

    OnBegin< override>()<suspends>:void=
  
        TriggerActivador.TriggeredEvent.Subscribe(ObtenerJugadores)

    ObtenerJugadores(Agent : ?agent):void=
        GenerarNumeros(GetPlayspace().GetPlayers())
                    
    GenerarNumeros(Players : []player) : void =

        for(Jugadores : Players):
            set NumeroAleatorioJugadores += array:
                SelectorNumeroAleatorio : int = GetRandomInt(MinimoAleatorio, MaximoAleatorio)

        ElectorMurder(Players)        

    ElectorMurder(Jugadores : []player) : void =

        var TemporalAleatorio : int = 0
        
        Values := for (X : NumeroAleatorioJugadores): 
    
            if(X >= TemporalAleatorio):
                set IndicadorJugadorMurder += 1
                set TemporalAleatorio = X

        if(IndicadorJugadorMurder <> -1):

            if(Player := Jugadores[IndicadorJugadorMurder]):

                ItemGranterAsesino.GrantItem(Player) 
                ElectorSheriff()

    ElectorSheriff(Jugadores : []player) : void =

        for(Player : Jugadores):
            var TemporalParaBorrarAleatorios : int = 0
            if (NewArray := NumeroAleatorioJugadores.RemoveElement[TemporalParaBorrarAleatorios]):
                set NumeroAleatorioJugadores = NewArray
            set TemporalParaBorrarAleatorios += 1    
            

        for(Player : Jugadores):
            set NumeroAleatorioJugadores += array:
                SelectorNumeroAleatorio : int = GetRandomInt(MinimoAleatorio, MaximoAleatorio)

        var TemporalAleatorio : int = 0
        
        Values := for (Y : NumeroAleatorioJugadores): 
    
            if(Y >= TemporalAleatorio):
                set IndicadorJugadorSheriff += 1
                set TemporalAleatorio = Y

        if(IndicadorJugadorSheriff <> -1 and IndicadorJugadorSheriff <> IndicadorJugadorMurder):

            if(Player := Jugadores[IndicadorJugadorMurder]):

                ItemGranterSheriff.GrantItem(Player)                 
        else:
            ElectorSheriff()
```

---

<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:** [August 29, 2024, 11:25am UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player-v/1982661/2 "2024-08-29T11:25:04Z")

</div>

Moved to the Verse forum.
