Hello, I’m trying to create a script editor for a game teaching how to script. The way I am going about it is I’m splitting the code up into lines that are frames, with each word being its own textbox. This will allow syntax highlighting. Problem is, I have found no way to get newlines from a string. I’m not talking about “\n” either, I’m talking:
local function wow()
print(“testfunction!”)
end
How would I go about separating each individual newline?
I am confused about what are you trying to find but print() function alreday close each line in the output. The problem you may be facing is that you are printing out multiple same values which Roblox studio starts to count instead of printing it out each line.
Frankly speaking, I have no clue how to do this, but I do know that if your string spans multiple lines, the \n character will implicitly exist. You’ll need to iterate through your string with a pattern and match cases of \n to determine where a newline is made.
Some test code I ran on the Lua demo page:
local a = [[local function wow()
print(“testfunction!”)
end]]
print(a:match("[^\n]*")) -- local function wow()
This should provide some direction as to what you should be doing. The code above finds one line of your string. The pattern set here is [^\n]*. Use this, along with other string functions and possibly also loops, to find all the lines of your string and what they contain.