# How to change player properties for multiple players at once?

**URL:** <https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, question\
**Created:** [February 12, 2024, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008 "2024-02-12T16:10:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![frenzyisegg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@frenzyisegg](https://forums.unrealengine.com/u/frenzyisegg)\
**Post date:** [February 12, 2024, 4:10pm UTC](https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008/1 "2024-02-12T16:10:51Z")

</div>

I originally had this code to update a health slider when a player interacted with a button which worked just fine:

> ```
> UpdateHealthSlider(Message: widget_message):void =
> Playspace: fort_playspace = GetPlayspace() # Create a playspace
> AllPlayers: []player = Playspace.GetPlayers() # Get all players and put in an array
> if(FirstPlayer: player = AllPlayers[0]):
> if(PlayerRefOne: fort_character = FirstPlayer.GetFortCharacter[]):
> TrueHealth := MyUIHealthSlider.GetValue()
> PlayerRefOne.SetMaxHealth(TrueHealth)
> PlayerRefOne.SetHealth(TrueHealth)
> return 
> 
> ```

However, I’d like all players in the game to be affected by the slider and I can’t figure out how to do it. I tried this:

> ```
> UpdateHealthSlider(Message: widget_message):void =
> Playspace: fort_playspace = GetPlayspace() # Create a playspace
> AllPlayers: []player = Playspace.GetPlayers() # Get all players and put in an array
> if((FirstPlayer: player = AllPlayers[0]) or (SecondPlayer: player = AllPlayers[1])):
> if((PlayerRefOne: fort_character = FirstPlayer.GetFortCharacter[]) and (PlayerRefTwo: fort_character = SecondPlayer.GetFortCharacter[])):
> TrueHealth := MyUIHealthSlider.GetValue()
> PlayerRefOne.SetMaxHealth(TrueHealth)
> PlayerRefOne.SetHealth(TrueHealth)
> PlayerRefTwo.SetMaxHealth(TrueHealth)
> PlayerRefTwo.SetHealth(TrueHealth)
> return
> 
> ```

The code won’t run without errors which is already an issue but, even if it did work, I’d have to add on lots of ineffiencient code to expand this to fit 6 players instead of 2.  
Is there any other way to change the player health/shields of the whole lobby?

---

<div class="post-metadata">

**Author:** ![The3v0luti0n](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/the3v0luti0n/32/897083_2.png) [@The3v0luti0n](https://forums.unrealengine.com/u/The3v0luti0n)\
**Post date:** [February 12, 2024, 5:06pm UTC](https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008/2 "2024-02-12T17:06:38Z")

</div>

I can see two ways of doing this.

The first solution could be to use the class system. Using a class designer device, you can easily change the health and shield for the class itself. If everyone is then assigned to the same class, you can therefore change the health and shield for every player!

The second option would be to just use a loop. The loop would go through all of the players in Playspace.GetPlayers(), reducing the amount of code involved. I don’t have the UEFN editor with me right now, but a quick example is something like…

```auto
AllPlayers : []player = Playspace.GetPlayers()

for (Player : AllPlayers):
    if (FortCharacter := Player.GetFortCharacter[]):
        # Do all the health stuff

```

This would go through all of the players in the AllPlayers array, and do the same action for each one.

---

<div class="post-metadata">

**Author:** ![frenzyisegg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@frenzyisegg](https://forums.unrealengine.com/u/frenzyisegg)\
**Post date:** [February 12, 2024, 5:48pm UTC](https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008/4 "2024-02-12T17:48:56Z")

</div>

thanks for the help! I thought of a for loop but have never learnt any fundamentals of C# or verse

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [March 13, 2024, 5:49pm UTC](https://forums.unrealengine.com/t/how-to-change-player-properties-for-multiple-players-at-once/1684008/5 "2024-03-13T17:49:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
