Go to new line in textbox

Very quick question, I don’t why I can’t find the answer.
I’m trying to go to a new line in a textbox when a button is pressed on the screen.
I tried concatenating “\n” to the end of the .Text property but that doesn’t work.
How do I accomplish this?

That’s to enable the ability to add lines with the enter key. On mobile keyboards (iOS atleast) the return key doesn’t seem to function as an enter. It simply closes the keyboard.

There’s a multi-line string ‘[[
]]’

For instance; TextLabel.Text = [[Hi,
Hello There!]] would change the text to be;

Hi,
Hello there!

Here’s an example I made;

https://gyazo.com/547a4edcb07941c1f5a9e42469c6ff60

Multi-line script;
image
Non Multi-Line script;
image

(Yes I know, my grammar is bad but I’m too lazy to fix it lmao.)

11 Likes

Unfortunately, I don’t believe that’s what I’m looking for. I want to insert a new line into a text box that already has text inside of it.
Basically creating a GUI button that functions like the enter button on a keyboard.

Okay then concatenate it. :slight_smile:

TextLabel.Text = TextLabel.Text…[[
]]

2 Likes

Ah, I didn’t know that would work. I’ll give it a try, should work!

1 Like

I tried doing that but it doesn’t seem to affect the text at all?
image
For context, Editor is the TextBox.

maybe try adding a “enter” (i don’t know a new line whatever it’s called xd) in the middle of the multi-line string;

Editor.Text = Editor.Text..[[

]]
1 Like

Thank you, it works! Finally mobile can at least somewhat use my box until I create a better solution.

No problem, you’re like the 2nd or 3rd person I’ve helped on the developer forum xd

Better option is to use the newline character. The character is “\n” use it as follows

Text = “Hey look im a string!\n hey look im on a new line!”

I tried concatenating “\n” to the end of the .Text property but that doesn’t work.

Doesn’t work.

2 Likes

You have to use string.format on it or it doesn’t work.

edit: heres how to use string.format: Strings | Documentation - Roblox Creator Hub

edit2: you use string.format(str, "%q") with str being your string containing \n

edit3: heres a code sample from the devhub:

local str = "Skip to \na new line and \nanother new line!"
print(string.format(str, "%q")) 
8 Likes

Oh wow somehow missed that. Sorry!