Is there a way to remove a new line?

Hello! So I’m making a Hand-To-Gui currently but the problem is, that you can just create a new line with enter and the script thinks that the name does actually have the new line in it. Is there a way to remove new lines?
image

1 Like

Refer to this post: Hitting enter in a textbox places a carriage return before finalizing input (broken again) - #29 by boatbomber

But I’ll say it here, do string.gsub(Input, "%c", "") to remove the \r.

3 Likes

To remove new lines or breaks from a multiline string,

local str = [[
ok
new

line]]             

print(str:gsub("%s", ""))

%s represents space and whitespace characters too,

image.

If it’s just new lines then string.gsub(str, "\n", "") would work too.

For carriage returns, \r and \n and to not remove gaps,

string.gsub(str, "[\r\n]", " ")

won’t remove spaces between words, only breaks will be removed.

Using a %c string pattern works for \r and \n both.

3 Likes