# How do I get the player counter number to display on a message hud device?

**URL:** <https://forums.unrealengine.com/t/how-do-i-get-the-player-counter-number-to-display-on-a-message-hud-device/1862968>\
**Category:** Verse\
**Tags:** error, unreal-editor-for-fortnite, fortnite-creative, UI, question, fortnite\
**Created:** [May 19, 2024, 8:33am UTC](https://forums.unrealengine.com/t/how-do-i-get-the-player-counter-number-to-display-on-a-message-hud-device/1862968 "2024-05-19T08:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![C0deVisionary](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/c0devisionary/32/883162_2.png) [@C0deVisionary](https://forums.unrealengine.com/u/C0deVisionary)\
**Post date:** [May 19, 2024, 8:33am UTC](https://forums.unrealengine.com/t/how-do-i-get-the-player-counter-number-to-display-on-a-message-hud-device/1862968/1 "2024-05-19T08:33:31Z")

</div>

I saw that [here](https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/player_counter_device/getcount), They have a function called “get count”. I want to use that function to show the player count in a message hud device that I set up earlier,  
How would I go about doing this?

---

<div class="post-metadata">

**Author:** ![BloomCx](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bloomcx/32/1203926_2.png) [@BloomCx](https://forums.unrealengine.com/u/BloomCx)\
**Post date:** [May 19, 2024, 1:57pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-player-counter-number-to-display-on-a-message-hud-device/1862968/2 "2024-05-19T13:57:13Z")

</div>

The HUD message device has a function called “SetText” which takes in a message as a parameter. Get the player count, convert it to a message, then update the HUD device text.

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

show_player_count := class(creative_device):

    @editable
    PlayerCounter : player_counter_device = player_counter_device{}
    
    @editable
    HudMessageDevice : hud_message_device = hud_message_device{}

    # Converts a string to a message
    StringToMessage<localizes>(String : string) : message = "{String}"
    
    OnBegin<override>()<suspends>:void=
        loop:
            # Update the text of the HUD device
            HudMessageDevice.SetText(StringToMessage("{PlayerCounter.GetCount()}"))
            # Render the updated HUD device
            HudMessageDevice.Show()
            Sleep(1.0)

```

---

<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:** [June 18, 2024, 1:58pm UTC](https://forums.unrealengine.com/t/how-do-i-get-the-player-counter-number-to-display-on-a-message-hud-device/1862968/3 "2024-06-18T13:58:12Z")

</div>

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