# How to add scores to all live players on each player elimination?

**URL:** <https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [September 15, 2023, 9:18am UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883 "2023-09-15T09:18:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtau](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomtau](https://forums.unrealengine.com/u/tomtau)\
**Post date:** [September 15, 2023, 9:18am UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/1 "2023-09-15T09:18:47Z")

</div>

I’d like to add a point to each live player whenever a player is eliminated. I did the following in my Verse device:

1. I added and bound the Score Manager:

```plaintext
    @editable ScoreManager : score_manager_device = score_manager_device{}

```

1. I have a map that tracks which players are eliminated:

```plaintext
    var PlayerMap : [fort_character]player_prof = map{}

```

1. I subscribe to all players’ eliminated events and initialize the map:

```plaintext
    OnBegin<override>()<suspends>:void=
        AllPlayers := GetPlayspace().GetPlayers()
        for (Player : AllPlayers, Agent := agent[Player], Fort := Agent.GetFortCharacter[]):
            Player.EliminatedEvent().Subscribe(OnEliminated)
            if (set PlayerMap[Fort] = false) {}

```

1. In `OnEliminated`, I set that the player was eliminated and use that bound score manager to add points to all non-eliminated players:

```plaintext
    OnEliminated(Elim0: elimination_result): void =
        Fort := Elim0.EliminatedCharacter
        if (P := PlayerMap[Fort]; set PlayerMap[Fort] = true):
            AllPlayers := GetPlayspace().GetPlayers()
            for (Player : AllPlayers, Agent := agent[Player], Fort2 := Agent.GetFortCharacter[], Fort2_eliminated := PlayerMap[Fort2], not (Fort2_eliminated?)):
                    ScoreManager.Increment(Agent)
                    ScoreManager.Activate(Agent)

```

Now, this works, but I found that when I have a game with 3+ players, it will sometimes log “VerseRuntimeErrors: Error: internal error occurred.” and the script will stop working. I’m not sure what exactly causes this error. Besides this happening with 3+ players, it seems to occur when two players are eliminated around the same time. I don’t know if it’s possible for UEFN to give more details on the internal error, but my blind guesses are:

- A bug of the concurrent map modification (I guess this shouldn’t occur based on the UEFN docs);
- A bug of having the `fort_character` type in the map (I saw some posts here or on Discord mentioning that having players, unlike primitive types, stored in a map could be problematic in the current UEFN version);
- A bug of accessing the map around the round end: I set it to be the “last man standing”, so a round should end when there’s only one player left, and I again saw some posts mentioning issues when accessing data around the round end…

For completeness, I added logs in different places and the last message before “VerseRuntimeErrors” was when adding the scores… I also tried removing the `ScoreManager` and adding the points in a custom map, and still hit that issue, so it seems it’s not due to the `ScoreManager`, but the map access.

Any other ideas? Or is there a different way to achieve the same thing?

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 15, 2023, 10:31am UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/2 "2023-09-15T10:31:49Z")

</div>

> [@tomtau](#):
>
> “VerseRuntimeErrors: Error: internal error occurred.”

This happens to me 50 times a day since the new update, are you using `weak_map()` somewhere in your code ? (see [Verse global variables no longer working, even on previous uploads](https://forums.unrealengine.com/t/verse-global-variables-no-longer-working-even-on-previous-uploads/1292404))

---

<div class="post-metadata">

**Author:** ![tomtau](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomtau](https://forums.unrealengine.com/u/tomtau)\
**Post date:** [September 15, 2023, 1:22pm UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/3 "2023-09-15T13:22:59Z")

</div>

Nope, just regular maps, but I saw those posts mentioning issues with weak\_map after the recent update.

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 15, 2023, 1:24pm UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/4 "2023-09-15T13:24:21Z")

</div>

Uhm, do you know what the ‘;’ does, I see you’re using it instead or ‘,’ ?

Also maybe remove the parentheses here : `not (Fort2_eliminated?)`

---

<div class="post-metadata">

**Author:** ![tomtau](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomtau](https://forums.unrealengine.com/u/tomtau)\
**Post date:** [September 15, 2023, 3:59pm UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/5 "2023-09-15T15:59:17Z")

</div>

Tried that and still the same 😢

---

<div class="post-metadata">

**Author:** ![tomtau](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tomtau](https://forums.unrealengine.com/u/tomtau)\
**Post date:** [September 15, 2023, 4:39pm UTC](https://forums.unrealengine.com/t/how-to-add-scores-to-all-live-players-on-each-player-elimination/1296883/6 "2023-09-15T16:39:49Z")

</div>

it turned out it was due to activating modulator device on eliminated players in a separate task, so far ok (hopefully).
