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

How do I make this script say "Hello Robloxians" (Part 2)?

I got the answer from someone, but what they gave me had an error. This is what I had for the script he answered:

function SayHello(Name)
print(Name..'!')
end
 
SayHello("Hello Narblet") OUTCOME --> Hello Narblet!
 
SayHello("Hello FUDGEWAD") OUTCOME --> Hello FUDGEWAD!

They are saying there is an error in Line 7. But I don't see what the problem is. Please help me.

1 answer

✓ Accepted answer

You can't include random pieces of English inside your program.

The Lua interpreter will believe it's code and cause problems.


If you need to include explanatory text, you have to use comments (using a double hyphen)

function SayHello(Name)
print(Name..'!')
end

SayHello("Hello Narblet")  -- Hello Narblet!

SayHello("Hello FUDGEWAD") -- Hello FUDGEWAD!

-- (or like this if you prefer):
-- OUTCOME --> Helo FUDGEWAD

(In this editor, comments (the stuff that Lua ignores) is highlighted green. Compare with what you originally posted)



From comments:

Comments don't do anything. The computer ignores them. So why would you ever have comments in code?

While they don't mean anything to Lua, they do (should) mean things to humans writing and reading code. You write comments to make explanations to yourself or to others using your code (like you had).

Good code includes comments.

On the other hand, since comments make Lua ignore pieces of the program, it's frequent that you'll see things like this:

x = x ^ 0.5
-- x = math.sqrt(x)

Where some code has been "commented out" to be ignored. While this can be convenient for debugging, in the long term it's almost universally considered to be bad practice to have this commented-out code remain.

5 comments

0

What do you mean the LUA would cause problems

1

The computer will treat everything except comments (the green things) as code, thus your error. Also Lua is not an acronym.

0

I mean the text would cause problems for Lua. If you were ordering food at a restaurant, and I said, "I would aghi like a oshaowiehei burger with oawihe no gof pickles asodifjasodjfi", you wouldn't get anywhere. You're including garbage that doesn't mean anything -- which confuses the waitress (or Lua, in this context)

0

So the green letters means nothing then. I shouldn't have included them?

0

Good code includes comments -- they can and should mean something to HUMANS -- (yourself or others using your code) -- but ultimately the computer will ignore them. Explanations are good to keep track of what's going on.

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