Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you use [[ and ]]?

I have tried using [[ and ]] but those attempts completely failed. Could someone help me?

These are my attempts:

code = [[print("testing")]]
code = [[print("testing")]]
code()

2 answers

✓ Accepted answer

[[ and ]] are used similarly to " and " but have the advantage of being able to be on multiple lines. So what your code is doing is just setting the variable code as a string. If you want to print something using [[ and ]] you should of done

print([[testing]])

4 comments

0

Thanks!

0

No problem C:

0

your* c:

0

c:

There are a few ways to write a String in Lua. The following are all identical strings:

print([[testing]])

print("testing")

print('testing')

Using double brackets is useful for two main reasons. The first, it allows for multi-line strings.

print([[testing

We skipped a line!]])

Another useful thing, is if your string has the other symbols for writing a string included:

--Assume our string is: How's it going, "bro?"

print("How's it going, "bro?"")	 --the " inside the string makes the strings; "How's it going, " and "" but Lua doesn't know with to do with them because there is no concatenation.



print('How's it going, "bro?"')	 --the ' inside the string makes the the string end earlier than it should



print([[How's it going, "bro?"]])  --Works great

This discussion is preserved as it was. New answers, comments, and votes are closed.