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

**URL:** <https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [August 17, 2024, 6:59pm UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532 "2024-08-17T18:59:37Z")\
**Posts on this page:** 4\
**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 17, 2024, 6:59pm UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532/1 "2024-08-17T18:59:37Z")

</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:** ![Hardcawcanary](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hardcawcanary/32/906569_2.png) [@Hardcawcanary](https://forums.unrealengine.com/u/Hardcawcanary)\
**Post date:** [August 19, 2024, 3:32pm UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532/2 "2024-08-19T15:32:25Z")

</div>

I don’t know verse, so I can’t point out the issue, but have you considered using player classes for the 3 different types.  
The class designers can give the loadouts and different devices can use the class settings to affect them differently

---

<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, 4:15pm UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532/3 "2024-08-19T16:15:56Z")

</div>

Thank you very much for your response, I really love people who try to help others! I have a great item just to test but just now I solved my problem after so long \<3

It turns out that I had a wrong “Conditional” and I also didn’t pick up and reset the variable that determines who has the gun, so I exceeded the number of players in the tests and no one had a gun 🙂

Thank you for your interest, if you need help, you can add to the discord, although I am Spanish but I am sure we understand each other \<3  
Discord: Fali\_005

---

<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 28, 2024, 10:18pm UTC](https://forums.unrealengine.com/t/why-doesnt-it-give-the-objects-to-the-selected-player/1980532/4 "2024-08-28T22:18:45Z")

</div>

Thank you for responding with your fix, @Fali 🙂
