# How to convert message type to string type?

**URL:** <https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321>\
**Category:** Programming & Scripting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [January 15, 2026, 11:45am UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321 "2026-01-15T11:45:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [January 15, 2026, 11:45am UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/1 "2026-01-15T11:45:21Z")

</div>

I am using a old function that adapts a string to a maximun number of char for a single line, so I add **line breaks** when the line is too long.

I need to convert the message to a string to use my old code or at least know how I can adapt my message to add **line break**

---

<div class="post-metadata">

**Author:** ![BRGJuanCruzMK](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brgjuancruzmk/32/1036548_2.png) [@BRGJuanCruzMK](https://forums.unrealengine.com/u/BRGJuanCruzMK)\
**Post date:** [January 15, 2026, 6:09pm UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/2 "2026-01-15T18:09:30Z")

</div>

Hey @davidpkami how are you?

You can use a code similar to this one to localize (not convert directly) you message to a string if the message contains variables inside:

```auto

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

message_to_string := class(creative_device):

    # Localizable message function that takes a player parameter and returns a formatted message
    MyMessage<localizes>(Player:player) : message = "Player: {Player}"
    
    # Editable button device that can be configured in the UEFN editor
    @editable
    MyButton : button_device = button_device{}

    # Override function that runs when the device starts in a running game
    OnBegin<override>()<suspends>:void=
        # Subscribe the OnButtonPressed function to the button's interaction event
        MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)

    # Function called when the button is pressed by an agent
    OnButtonPressed(Agent : agent) : void =
        # Get all players currently in the playspace
        AllPlayers := GetPlayspace().GetPlayers()
        # Check if there is at least one player and assign it to FirstPlayer
        if (FirstPlayer := AllPlayers[0]):
            # Call MyMessage function with the first player to generate a localized message
            MessageWithPlayer := MyMessage(FirstPlayer)
            # Convert the message to a string using Localize()
            MyString : string = Localize(MessageWithPlayer)
            # Print the converted string to the UEFN log
            Print("Converted message to string: {MyString}")
```

Keep in mind that if you are using player names, for instance, you won’t get the real player name but something like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/7/9273a633d59227bf3c8bf6bb4f229fa6538cf25d.jpeg)

This happens becasue player names are not available as a string in UEFN.

If the message is only text, you can use this code instead:

```auto

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

message_to_string := class(creative_device):

    # Localizable message function that takes a player parameter and returns a formatted message
    MyMessage<localizes> : message = "Hello World!"
    
    # Editable button device that can be configured in the UEFN editor
    @editable
    MyButton : button_device = button_device{}

    # Override function that runs when the device starts in a running game
    OnBegin<override>()<suspends>:void=
        # Subscribe the OnButtonPressed function to the button's interaction event
        MyButton.InteractedWithEvent.Subscribe(OnButtonPressed)

    # Function called when the button is pressed by an agent
    OnButtonPressed(Agent : agent) : void =
        MyString : string = Localize(MyMessage)
        Print("Converted message to string: {MyString}")
```

Hope this helps you!

---

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [February 19, 2026, 11:04am UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/3 "2026-02-19T11:04:41Z")

</div>

I have used this in my project, but it seems that it does not work and the messages are not localized

```verse
if(ValidMessage := MaybeNextMessage?):
                    DescriptionString_Final:=AdaptStringToLineV2(Localize(ValidMessage),40)
                    CharacterMessage_TextBlock.SetText(BasicMessage(DescriptionString_Final))

```

I localice the Message and after creating the string I use a custom function to slice the phrase if it is too long in to lines.

The message does not get localized

---

<div class="post-metadata">

**Author:** ![Sprintermax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sprintermax/32/1037175_2.png) [@Sprintermax](https://forums.unrealengine.com/u/Sprintermax)\
**Post date:** [February 19, 2026, 3:09pm UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/4 "2026-02-19T15:09:43Z")

</div>

That’s correct, `Localize()` uses the language configured on the application (and since verse runs on server, it is always english)

There is no `Localize(Message, "en-US")`, `Localize(Message, "pt-BR")` and so on.

Localized messages are not meant to be post-processed (edited, trimmed or so on), it is supposed to be static.

For line breaks you should enable Text Wrap on the Text Block Widget. In verse it has not this option but you can workaround by making a single text widget with verse field for that… That approach is also way better than manipulating character sizes in verse from scratch (since it has lots of bugs, characters are not all same sizes and so on)

---

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [February 19, 2026, 3:56pm UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/5 "2026-02-19T15:56:08Z")

</div>

Oh I did not know that possibility. Is there anywhere where it explain how to do it?

---

<div class="post-metadata">

**Author:** ![Sprintermax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sprintermax/32/1037175_2.png) [@Sprintermax](https://forums.unrealengine.com/u/Sprintermax)\
**Post date:** [February 19, 2026, 5:32pm UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/6 "2026-02-19T17:32:59Z")

</div>

It is very simple like any other widget setup:

 ![2026-02-19 14_31_23-Unreal Editor for Fortnite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/d/0/9d040874ac4b3700cba963243f9e81d65bbce0e6.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/5/215cd37742c29605a061f839840a5ea29cfbccf0.png)  
 ![2026-02-19 14_31_16-Unreal Editor for Fortnite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/0/a30617079b8606e37a602d7c1f54ab8fbfa864d5.png)  
 ![2026-02-19 14_31_19-Unreal Editor for Fortnite](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/7/847b629c59ece8a5049cdbbe62b88f2bc5c69f6a.png)

---

<div class="post-metadata">

**Author:** ![davidpkami](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/davidpkami/32/1040403_2.png) [@davidpkami](https://forums.unrealengine.com/u/davidpkami)\
**Post date:** [February 19, 2026, 10:56pm UTC](https://forums.unrealengine.com/t/how-to-convert-message-type-to-string-type/2692321/7 "2026-02-19T22:56:09Z")

</div>

How I use this on code?
