Read error messages like a pro — which script, which line, and what went wrong.
When your code has a problem, the Output window gets red lines. That scary-looking line is actually a gift: it tells you exactly where the problem is and what it is.
Say you run a and Output shows this:
Workspace.Script:3: attempt to call a nil value
Read it left to right:
You won't understand every error yet. But notice how much information is there.
What does an error message like 'Workspace.Script:3' tell you?
Open your from the last lesson, the one that prints a message. You're going to break it on purpose, in a safe place where nothing real can be lost.
First, notice what doesn't break. Delete the text inside the parentheses so the line reads:
print()
Press Play. Output shows an empty line, not a red one. print() doesn't need anything between the parentheses — with nothing to print, it prints a blank line. Not everything you see in Output is an error.
You run a script containing only print(). What does Output show?
To make a real one, replace the line with this:
error("I broke it on purpose")
Press Play. Output turns red:
Workspace.Script:1: I broke it on purpose
Read it with the anatomy from the first step: which (Workspace.Script), which line (:1), and the problem — the message you gave it. error() is the whose whole job is to stop a and leave that red line behind.
That's success. You just created your first real error on purpose, on your terms, in a safe empty place. An error doesn't mean you broke your game — it means that one line stopped. Read the message, fix the line, try again.
When something doesn't work, look at the Output window before you look anywhere else. Not the 3D view, not your 's spelling — Output. The message names the and the line, so you can go straight there.
An error message names the script, the , and the problem.