Literacy with GDScript

Godot Version

Godot Engine v4.7.2 Stable Official

Question

Hi, I’m fairly new to Godot and I’d just like to ask how may one become proficient at GDScript literacy or using the documentation?

I know how to make nodes, scene trees, and some coding/Godot basics from the Make Your Own Computer Games with Python book and the Learn GDScript from Zero free interactive web application, but I keep finding my self lacking in how to implement what I need to code, or reading the documentation.

Like I tried to make a parallax moving background, so I attached a script to the Parallax root node and typed the scroll scale code, that the parallax documentation said I needed, here from the documentation under my physics delta function:

#Documentation:
void set_scroll_scale(value: Vector2)
Vector2 get_scroll_scale()

#My script code using documentation as reference:
extends Node2D

# Higher numbers mean a faster moving background
@export var scroll_speed: float = -200.0 

@onready var parallax_layer: Parallax2D = $Parallax2D

func _process(delta: float) -> void:
	# Continuously add to the X offset based on time and speed
	$Background.scroll_offset.x += scroll_speed * delta
	scroll_scale = Vector2(1, 1)
	Vector2 get_scroll_scale()

but I keep getting errors no matter how I adjust it. The rest of the code aside from the scroll scale was automatically written when I created the script. Sorry if I’m rambling, but I just don’t know whether I even did the right tutorials or if I’m reading the documentation correctly.

It helps us help you if you include the exact error message you get.

What I immediately notice is that in the very first line, you forgot to include a : at the end of the line, and you didn’t ident the next line under it.

extends Node should be at the very top of your script.

The last line makes no sense, you are trying to put a value into a variable type.

You’re on the right track. The main issue is that get_scroll_scale() is a method, not something you write by itself; you need to call it on the correct Parallax2D node. Don’t worry about memorizing the docs—keep building small things and learn to look up the class, property, or method you need.

The area of knowledge you are taking on is wast and naturally disorienting at first. Don’t get discouraged and keep trying, reading, asking questions. There is alot of parts to wrap your head around, deal with them one by one and as they take their places the things will begin to make sense.

Regarding GDscript literacy specifically, it may help to read existing scripts that work. Read through, figure out why every part of it is there, what it does and how. Then change some things as an experiment and try to make it do something else. Then write your own functions, and eventually whole scripts.

I apologize, the error was " Error at (12, 5): Expected end of statement after expression, found “Identifier” instead. "

Thank you, also could you clarify what you mean by existing scripts? Are they found in the documentation?

Thank you for your response.

I guess my main issue is that I don’t know what else I need to code. Like I know I must code a parallax moving node but I don’t know what code to use and what other procedures are required. I’m also not sure if I copy and paste the words in the documentation or they have to be implemented somewhere else.

There are GitHub - godotengine/godot-demo-projects: Demonstration and Template Projects · GitHub that demonstrate various features of the engine. Import a project into editor and dig around its scripts. Then there are scripts and projects in the Godot Asset Library. You can also just google up some projects by other people like godot-example · GitHub Topics · GitHub , these may be not up to date but probably still useful.

Thank you, I’ll make sure I study it.