This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

So I have a Popup menu and I have a label in it, I want the label to display stats like:

Wins: 5
Losses: 8
Ties: 3

Where each stat is on a new line, in a single label. Some languages such as C has a feature where you add in \n in string to go to a new line. How do I do this in GDScript? I'm editing the text from a script.

Godot version Godot Engine v3.4.3.stable
in Engine by (37 points)
edited by

4 Answers

+4 votes
Best answer

Em. Well, it's actually \n

Or you can use triple quotes to make multiline string in script like that:

$Label.text = """Wins: 5
Losses: 8
Ties: 3"""
by (654 points)
selected by
+1 vote

\n is working fine for me. Try get_node(your label).set_text("LINE1\nLINE2")

Edit: someone was 13 seconds faster...

by (31 points)
0 votes


by (14 points)

Mark this answer as Funny

0 votes

I've just had a similar problem. I've written to a txt file (as a test), and checked the result from the standard windows txt-editor. The newline character is there, just the txt-editor did not want to show me, and wrote the whole thing in one line.

by (24 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.