GDScript Basics
Learn GDScript fundamentals: variables, functions, control flow, and object-oriented patterns.
Scripting
No shortcutBeginner7 min readQuick Reference
GDScript Basics
Godot EngineKeyboard Shortcut
N/A
Where to Find
Select any node → Click Attach Script button, or Script Editor panel
Best Used For
- ▸Write game logic with variables and functions
- ▸Connect nodes via signals for decoupled systems
- ▸Expose Inspector properties for designer tweaking
Beginner-Friendly⏱ 15–30 minutes to master
Key Settings
Variables:Functions:Control flow:Signals:
GDScript is Godot's primary scripting language. It has Python-like syntax and is tightly integrated with the engine. Every node can have a script attached to define its behavior.
Where to Find It
Attach a script to any node by selecting it and clicking the Attach Script button in the Inspector, or right-click in Scene dock.
How to Use
- Variables: Use
var health = 100to declare variables. - Functions: Define with
func _ready():for built-in callbacks. - Control flow: Use
if,for,whilelike Python. - Signals: Emit and connect custom signals for event-driven code.
- Export: Use
@export var speed = 300to expose variables in Inspector.
Pro Tips
- Use
@onready varfor nodes that are accessed after_ready(). - Use type hints (
var health: int) for better editor support. - Use
matchinstead of nestedif/eliffor cleaner code.