# Display large numbers with commas

**URL:** <https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [November 25, 2023, 6:51am UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275 "2023-11-25T06:51:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Razza994](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Razza994](https://forums.unrealengine.com/u/Razza994)\
**Post date:** [November 25, 2023, 6:51am UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275/1 "2023-11-25T06:51:59Z")

</div>

Hi There. I have used verse to display variable text on the players HUD. I am just trying to figure out how I can make the numbers read with commas. Eg. 1000 would display as 1,000 and 1000000 would display as 1,000,000 and so on. I have attached the code below:

```auto
using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Colors/NamedColors }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Assets }
 
# A Verse-authored creative device that can be placed in a level
ResourceUIDevice := class(creative_device):
 
    S2M<localizes>(S:string):message="{S}"
 
    @editable PlayerSpawners : []player_spawner_device = array{}
    @editable RefreshRate : float = 0.1
    @editable ConditButton : conditional_button_device = conditional_button_device{}
    var ResourceTextBlockPerAgent : [agent]?text_block = map{}
 
    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        for(PS:PlayerSpawners):
            PS.SpawnedEvent.Subscribe(PlayerSpawned)
 
    PlayerSpawned(Agent:agent):void=
        Print("Player Spawned")
        if(MyTextBlock:=ResourceTextBlockPerAgent[Agent]?){}
        else:
            AssignUI(Agent)
 
    AssignUI(Agent:agent):void=
        Print("Assigning UI")
        MyCanvas:=MakeCanvas(Agent)
        if:
            PlayerUI:=GetPlayerUI[player[Agent]]
        then:
            PlayerUI.AddWidget(MyCanvas)
            spawn{RefreshUI(Agent)}
 
    RefreshUI(Agent:agent)<suspends>:void=
        Print("Starting to Refresh")
        if(TextBlock := ResourceTextBlockPerAgent[Agent]?):
            loop:
                Sleep(RefreshRate)
                MyResource := ConditButton.GetItemCount(Agent,0)
                TextBlock.SetText(S2M("{MyResource}"))
 
 
 
    MakeCanvas(Agent:agent):canvas=
        Print("Making Canvas")
        MyTextBlock:=text_block:
            DefaultTextColor:=White
 
        if(set ResourceTextBlockPerAgent[Agent] = option{MyTextBlock}){}

 
        MyCanvas:=canvas:
            Slots:=array:
                canvas_slot:
                    Widget:=MyTextBlock
                    Anchors:=anchors{Minimum:=vector2{X:=0.0,Y:=0.0},Maximum:=vector2{X:=1.0,Y:=1.0}}
                    Offsets:=margin{Left:=216.0,Top:=820.0,Right:=1481.0,Bottom:=211.0}
                
                

        return MyCanvas

```

---

<div class="post-metadata">

**Author:** ![Afflictor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/afflictor/32/484061_2.png) [@Afflictor](https://forums.unrealengine.com/u/Afflictor)\
**Post date:** [November 28, 2023, 3:14am UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275/2 "2023-11-28T03:14:58Z")

</div>

There’s some code here: [Functions to work with ridiculously big numbers. | Uefn Code Snippet](https://dev.epicgames.com/community/snippets/wpbL/fortnite-functions-to-work-with-ridiculously-big-numbers)

hope that helps!

---

<div class="post-metadata">

**Author:** ![Afflictor](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/afflictor/32/484061_2.png) [@Afflictor](https://forums.unrealengine.com/u/Afflictor)\
**Post date:** [December 17, 2023, 7:00pm UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275/3 "2023-12-17T19:00:41Z")

</div>

I finally figured it out. In your code change the following:  
S̶2̶M̶\<l̶o̶c̶a̶l̶i̶z̶e̶s̶\>(̶S̶:̶s̶t̶r̶i̶n̶g̶)̶:̶m̶e̶s̶s̶a̶g̶e̶=̶"{̶S̶}̶"  
S2M(S:int):message=“${S}”

and

T̶e̶x̶t̶B̶l̶o̶c̶k̶.S̶e̶t̶T̶e̶x̶t̶(̶S̶2̶M̶(̶"{̶M̶y̶R̶e̶s̶o̶u̶r̶c̶e̶}̶")̶)̶  
TextBlock.SetText(S2M(MyResource))

---

<div class="post-metadata">

**Author:** ![Razza994](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Razza994](https://forums.unrealengine.com/u/Razza994)\
**Post date:** [December 20, 2023, 10:36am UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275/4 "2023-12-20T10:36:50Z")

</div>

yeah i figured it out a couple of weeks ago and just forgot to mention it here. I did it the exact way you did it so I have marked it as the answer. Thanks

---

<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:** [January 19, 2024, 10:37am UTC](https://forums.unrealengine.com/t/display-large-numbers-with-commas/1419275/5 "2024-01-19T10:37:34Z")

</div>

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