# How do I Show a UI Widget and Update it to Every Player in game

**URL:** <https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, Widget, question, fortnite\
**Created:** [July 21, 2023, 4:29am UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478 "2023-07-21T04:29:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![YouTube\_Giova](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YouTube\_Giova](https://forums.unrealengine.com/u/YouTube_Giova)\
**Post date:** [July 21, 2023, 4:29am UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/1 "2023-07-21T04:29:29Z")

</div>

Hello! I’m making a Boss Battle and I found this tutorial online with this code [Code for boss fight and health bar in UEFN and Verse · GitHub](https://gist.github.com/WahlbeckUEFN/75466e07ae70b185e6710ace203d4cd7)

It works fine but when I try to give the UI to multiple players things stop working.  
The health bar doesn’t update and only 1 player can see the working health bar.

I use for loop to get all players and give each player the UI.

Like

```
    AllPlayers := GetPlayspace().GetPlayers()
    
    for (X := 0..16):
    if (Player := AllPlayers[X]):
        BossHPBar.ShowUIForPlayer(Player) 

```

Every player can see the boss health bar but it doesnt update when the boss is hit.

This is the map code if you want to check the bug for yourself lol 4085-2886-5650

I would appreciate the help! 🙂

---

<div class="post-metadata">

**Author:** ![Fredbenz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fredbenz](https://forums.unrealengine.com/u/Fredbenz)\
**Post date:** [September 11, 2023, 12:22am UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/2 "2023-09-11T00:22:59Z")

</div>

Did you ever get an answer? I tried it a similar way and couldn’t get it working… yet.

I can’t figure out why this doesn’t display it for all players. Rather, it shows it to just one player.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/5/095f0d3c7aa5a35e31e431334d32f5e15673237d.png)

---

<div class="post-metadata">

**Author:** ![YouTube\_Giova](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YouTube\_Giova](https://forums.unrealengine.com/u/YouTube_Giova)\
**Post date:** [September 11, 2023, 5:02pm UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/3 "2023-09-11T17:02:40Z")

</div>

I found it by myself, you have to make an UI class then a Map for that UI Class

> var UIManagerMap : [player]UIManager = map {}

> UIManager := class():

```
Player: player
Agent: agent

var Canvas<internal> : canvas = canvas{}

block:
    set Canvas = canvas:
        Slots := array:
            canvas_slot:
                Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.1}, Maximum := vector2{X := 0.5, Y := 0.1}}
                Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                Alignment := vector2{X := 0.5, Y := 0.5}
                Widget := overlay:
                    Slots := array:
                        overlay_slot:
                            Widget := color_block:
                                DefaultColor := NamedColors.Blue
                                DefaultOpacity := 0.7
                                DefaultDesiredSize := vector2{X := 256.0, Y := 128.0}
                        overlay_slot:
                            Widget := stack_box:
                                Orientation := orientation.Vertical
                                Slots := array:
                                    stack_box_slot:
                                        Widget := JumpTextWidget
                                    stack_box_slot:
                                        Widget := DiamondTextWidget

JumpText<private><localizes>(JText : string) : message = "Gas: {JText}"
DiamondText<private><localizes>(DText : string) : message = "Diamonds: {DText}"   
                                              

JumpTextWidget:text_block = text_block{
    DefaultShadowColor := MakeColorFromHex("#000000")
    DefaultShadowOffset := option{vector2{X:= 0.5, Y:= 0.5}} 
    DefaultTextColor := MakeColorFromHex("#FFFFFF")
}   

DiamondTextWidget:text_block = text_block{
    DefaultShadowColor := MakeColorFromHex("#000000")
    DefaultShadowOffset := option{vector2{X:= 0.5, Y:= 0.5}} 
    DefaultTextColor := MakeColorFromHex("#00FFFF")
} 

UpdateUI(Jump: int, Diamond: int): void=
        #update ui
        JumpTextWidget.SetText(JumpText("{Jump}"))
        DiamondTextWidget.SetText(DiamondText("{Diamond}"))

        #set shadow to text
        JumpTextWidget.SetShadowOpacity(1.0)
        DiamondTextWidget.SetShadowOpacity(1.0)

```

Then you need to show each UI class to each player

> if(MyUIMap := UIManagerMap[Player], PlayerUI := GetPlayerUI[Player]):  
> PlayerUI.AddWidget(MyUIMap.Canvas)  
> Print(“ADDED CANVAS”)

---

<div class="post-metadata">

**Author:** ![Fredbenz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fredbenz](https://forums.unrealengine.com/u/Fredbenz)\
**Post date:** [September 11, 2023, 5:06pm UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/4 "2023-09-11T17:06:04Z")

</div>

Thanks for the info.

I sort of came to that conclusion as well. What I found was that I had to generate a different canvas for each player in order to get it to display to the players. Once I figured that out I figured I was going to have to dedicated a class to this functionality. I started down this road but I think what you just showed is a far more simplistic (meant to read ‘elegant’) way. I will be giving your way a shot.

Thanks a lot of responding and for doing so quickly!

---

<div class="post-metadata">

**Author:** ![UNREG](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/unreg/32/740541_2.png) [@UNREG](https://forums.unrealengine.com/u/UNREG)\
**Post date:** [September 28, 2023, 8:16pm UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/5 "2023-09-28T20:16:09Z")

</div>

Sorry fo the nooby question but where do you place this in your code ?

```auto
if(MyUIMap := UIManagerMap[Player], PlayerUI := GetPlayerUI[Player]):
PlayerUI.AddWidget(MyUIMap.Canvas)
Print(“ADDED CANVAS”)

```

---

<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:** [October 28, 2023, 8:16pm UTC](https://forums.unrealengine.com/t/how-do-i-show-a-ui-widget-and-update-it-to-every-player-in-game/1235478/6 "2023-10-28T20:16:53Z")

</div>

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