✓ Accepted answer
Problem
On line 3 of your second example, you create a single-line string value. This means your string value only spans one line of code, before being cut off. If the string value isn't ended on the same line of code it started on, it will consider the string non-terminating, thus breaking the script with a syntax error.
Multi-line strings
What you're looking for is a multi-line string value. This string can be created using 2 square braces ([[), and ending with 2 square braces (]]).
Here's a revised version of your code:
local h = Instance.new("Message")
h.Parent = Workspace
h.Text = [[be sure to push the button
then stand on the red brick]]
wait(5)
h:Destroy()
Or, if you wanted to have the actual text of [[ or ]] in your string, you could start your string with a single bracket, and equal sign, and another single bracket (like this: [=[).
Example:
print([=[
hello [[world]]
]=])
Escape characters
An alternative to the above example would be using an escape character (the \ symbol). This symbol allows us the escape a string pattern, or avoid terminating one. We could use this symbol before what would terminate our string, to "extend" it's length.
For example, let's say we wanted a quotation mark within a single-line string. We could say:
print("hello 'world'")
or...
print('hello "world"')
or finally...
print("hello \"world\"")
Hope this helped!
1 comment
it worked! thx