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

What does a blank mean?

I am often seeing an underscore (usually followed by a comma) in scripts. However, I am unable to find information on what this is or what it does. What does _ or _, mean in scripting?

2 answers

✓ Accepted answer

This question has already been asked and here is my answer to it


_ is called the underscore.


The underscore is treated by Lua exactly like a letter (a-z, A-Z). It is used in variable names, or on its own (just like you could use x as a variable name, you can use _ as a variable name).


Since spaces aren't allowed in variable names, some styles suggest using the underscore as a space, as opposed to using camelCase or PascalCase: multi_word.


In addition, some built in Lua names use it, including _G, the global table, and the metamethods, which are preceded by two underscores, e.g, __index.


Usually, when _ is used as a variable name, it is to indicate that its value is not important.

Since some functions, like the iterators pairs and ipairs, return two values, you need to give a name to the first value even if you aren't going to use it. Stylistically, the _ is sometimes used to note that.

It is only a stylistic convention and is nothing special, though.

Well i believe it has 2 purposes... The first purpose is to act as a variable name. The second purpose is _G that is a global variable. I believe that is all there is too _...

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