Menu
CoddyTech

Comments

Part of the Fundamentals section of Coddy's GDScript journey. Lesson 3 of 92.

Comments are notes you write inside your code. GDScript ignores them: they are there to help people read the code.

A comment starts with #. Everything after # on that line is ignored:

# This is a comment
print("Hello!")

A comment can also follow code on the same line:

print("Hello!") # This prints Hello!

GDScript has no special syntax for multi-line comments. Start each line with #:

# This program greets the player.
# It runs once, at the start.
print("Welcome!")

A comment can also disable a line of code without deleting it:

# print("This line does NOT run")
print("This line runs")

An indented block cannot be empty. If you comment out every line under func _ready():, add pass, a statement that does nothing, so the block still has a line to run.

challenge icon

Challenge

Beginner

The program prints two lines. Turn the line that prints Goodbye! into a comment, so the program prints only:

Hello!

Do not delete the line: put # in front of it.

Try it yourself

extends Node

func _ready():
	print("Hello!")
	print("Goodbye!")
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals

Practice on your own: Online GDScript compiler