# Quick way to display text to player's screen from Verse script

**URL:** <https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [March 29, 2023, 12:02pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948 "2023-03-29T12:02:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KingJArthur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingjarthur/32/639252_2.png) [@KingJArthur](https://forums.unrealengine.com/u/KingJArthur)\
**Post date:** [March 29, 2023, 12:02pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/1 "2023-03-29T12:02:05Z")

</div>

I just want to display a message on the players screen for a few seconds, like “Your 4th elimination!” or “You need one more kill!”. Is there an already baked interface to do that without getting too fancy?

---

<div class="post-metadata">

**Author:** ![lwillsl](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lwillsl/32/651027_2.png) [@lwillsl](https://forums.unrealengine.com/u/lwillsl)\
**Post date:** [March 29, 2023, 1:06pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/2 "2023-03-29T13:06:32Z")

</div>

You can use [HUD Message Devices](https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-hud-message-devices-in-fortnite-creative) for that.

---

<div class="post-metadata">

**Author:** ![KingJArthur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingjarthur/32/639252_2.png) [@KingJArthur](https://forums.unrealengine.com/u/KingJArthur)\
**Post date:** [March 29, 2023, 1:39pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/3 "2023-03-29T13:39:35Z")

</div>

Thank you. I’m trying to set the message in my Verse script, apparently you can’t pass a direct string, nor directly create a message object. So I’m just trying to figure that out now…

```auto
     HUDMessageDevice.SetText("Eliminations for this phase: {PlayerElimsForCurrentPhase}")
        HUDMessageDevice.Show()

```

---

<div class="post-metadata">

**Author:** ![KingJArthur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingjarthur/32/639252_2.png) [@KingJArthur](https://forums.unrealengine.com/u/KingJArthur)\
**Post date:** [March 29, 2023, 3:01pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/4 "2023-03-29T15:01:06Z")

</div>

So, it looks like I can set a text value in the UEFN editor for the hud\_message\_device, and that works. But I have no way to dynamically insert a number into that text (which I calculate in Verse). Unless I created a different hud\_message\_device for every possible number I’d want to display…which would be bad.

---

<div class="post-metadata">

**Author:** ![DustinREDGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dustinredgames/32/634988_2.png) [@DustinREDGames](https://forums.unrealengine.com/u/DustinREDGames)\
**Post date:** [March 29, 2023, 3:42pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/5 "2023-03-29T15:42:52Z")

</div>

Here is an example of displaying dynamic text on the screen, changing a value, and updating the text.

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

dynamic_text_device := class(creative_device):    

    var _myIntValue:int = 0
    var _textWiget: text_block = text_block{DefaultTextColor:= color{R:=1.0, G:=1.0, B:=1.0}}

    OnBegin<override>()<suspends>:void=
        # set UI on a player
        var players:[]player = Self.GetPlayspace().GetPlayers()
        if (ValidPlayer := players[0]):
            AddUIToPlayer(ValidPlayer)

        Sleep(5.0)

        # change values, update UI
        set _myIntValue = 12345
        UpdateUI()

    AddUIToPlayer(Player:agent):void=
        if (PlayerUI := GetPlayerUI[player[Player]]):
            PlayerUI.AddWidget(CreateUI())

    CreateUI() : canvas =        
        UpdateUI()
        # align top center of screen
        ui : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.0}, Maximum := vector2{X := 0.5, Y := 0.0} }
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.0}
                    SizeToContent := true
                    Widget := _textWiget

        return ui

    UpdateUI():void=
        _textWiget.SetText(SetDynamicText(_myIntValue))

    SetDynamicText<localizes>(IntValue:int) : message = "Dynamic text {IntValue}"

```

---

<div class="post-metadata">

**Author:** ![KingJArthur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kingjarthur/32/639252_2.png) [@KingJArthur](https://forums.unrealengine.com/u/KingJArthur)\
**Post date:** [March 29, 2023, 6:47pm UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/6 "2023-03-29T18:47:35Z")

</div>

> [@DustinREDGames](#):
>
> ` SetDynamicText<localizes>(IntValue:int) : message = "Dynamic text {IntValue}"`

This was awesome. I was even able to get my existing code to work just by using your ‘localizes’ function!

---

<div class="post-metadata">

**Author:** ![ok\_studios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ok\_studios](https://forums.unrealengine.com/u/ok_studios)\
**Post date:** [November 25, 2023, 8:20am UTC](https://forums.unrealengine.com/t/quick-way-to-display-text-to-players-screen-from-verse-script/831948/7 "2023-11-25T08:20:18Z")

</div>

Does anyone know how to structure the line of code to turn off the display text once it is done? I see there is a Set Visibility and widget\_visibility option but how to set it up is the question? Thank you.
