# How can I make it so player killing themselves does not work

**URL:** <https://forums.unrealengine.com/t/how-can-i-make-it-so-player-killing-themselves-does-not-work/1401527>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [November 18, 2023, 7:53pm UTC](https://forums.unrealengine.com/t/how-can-i-make-it-so-player-killing-themselves-does-not-work/1401527 "2023-11-18T19:53:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pinkskyee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pinkskyee](https://forums.unrealengine.com/u/pinkskyee)\
**Post date:** [November 18, 2023, 7:53pm UTC](https://forums.unrealengine.com/t/how-can-i-make-it-so-player-killing-themselves-does-not-work/1401527/1 "2023-11-18T19:53:06Z")

</div>

# Here is my code so far, I need it so my code does not count killing yourself as a kill for # gun game

```auto
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }

elimination_game_device := class(creative_device):

    @editable
    EndGameDevice : end_game_device = end_game_device{}

    # Array of item granters used to grant the weapons
    @editable
    var WeaponItemGranters : []item_granter_device = array{}
    
    # This is set later, this will be equal to the the number of weapon item_granters in the island
    var NumberOfEliminationsToWin : int = 0
    # Map container to track players progress. This is how to determine which weapon to award to the player
    var AgentMap : [agent]int = map{}

    #Checking for new players

    OnPlayerAdded(InPlayer : player) : void =
        AllPlayers := GetPlayspace().GetPlayers()

    # Check if the victory condition has been met and return the the result
    IsVictoryConditionMet(EliminationNumber:int)<transacts>:logic=
        if:
            EliminationNumber = NumberOfEliminationsToWin
        then:
            return true
        else:
            return false

    #Ending game once player reaches goal
    EndGame(Agent:agent):void=
        EndGameDevice.Activate(Agent)

    # Check if there is a winner for the game, if not then grant the next weapon
    GrantNextWeapon(Agent:agent):void=
        if(PlayerObj := player[Agent]):
            if (var CurrentItemNumber:int = AgentMap[Agent]):
                if (IsVictoryConditionMet(CurrentItemNumber) = true):
                    EndGame(Agent) # Game has been won
                else: # Game is not over yet
                    set CurrentItemNumber = CurrentItemNumber + 1
                    if (ItemGranter := WeaponItemGranters[CurrentItemNumber - 1]):
                        ItemGranter.GrantItem(Agent)
                    
                    if (set AgentMap[Agent] = CurrentItemNumber) {}

    # Event that handles when a player is eliminated
    OnPlayerEliminated(Result:elimination_result):void=
        Print("Player Eliminated")
        # Character who was eliminated
        Eliminated := Result.EliminatedCharacter
        # Character who killed other
        Eliminator := Result.EliminatingCharacter
        if (FortCharacter := Eliminator? ,EliminatingAgent := FortCharacter.GetAgent[]):
            Print("Elimation through if statement")
            GrantNextWeapon(EliminatingAgent)
            Print("Player Has Killed Themselves")

    OnBegin<override>()<suspends>:void=
        Sleep(0.0)
        # Can use this variable to scale the number of eliminations needed based on how many item granters there are in the experience
        set NumberOfEliminationsToWin = WeaponItemGranters.Length
        Print("Number of Weapon Item Granters: {WeaponItemGranters.Length}")
        
        # Randomize the order in which the weapons are granted
        # set WeaponItemGranters = Shuffle(WeaponItemGranters)

        Self.GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)

        # Get all the players in the experience

        AllPlayers := GetPlayspace().GetPlayers()
        
        for (EliminationGamePlayer : AllPlayers):
            if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
                FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated) # subscribe to eliminated event
            
            # Add Players to a Map to track progress
            if (set AgentMap[EliminationGamePlayer] = 1) {} 
            
            # Grant the first weapon to each player
            if (FirstItemGranter:item_granter_device = WeaponItemGranters[0]):
                FirstItemGranter.GrantItem(EliminationGamePlayer) 

```

---

<div class="post-metadata">

**Author:** ![djpixel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@djpixel](https://forums.unrealengine.com/u/djpixel)\
**Post date:** [November 19, 2023, 7:07am UTC](https://forums.unrealengine.com/t/how-can-i-make-it-so-player-killing-themselves-does-not-work/1401527/2 "2023-11-19T07:07:28Z")

</div>

I might be wrong, but I believe you can compare eliminator and eliminated.  
If they are the same, then this player had eliminated themselves.

```auto
if (Eliminated = Eliminator?):
    Print("Player Has Eliminated Themselves")

```
