nothings printing

Godot Version

4.2.2

Question

it doesnt print anything with this code:

extends Node2D

var score = 5

Called when the node enters the scene tree for the first time.

func _ready():
print(score)

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta):
pass
any ideas? i just started yesterday with godot

Hello! You didn’t indent. The code should look like

extends Node2D

var score = 5

func _ready():
	print(score)

func _process(delta):
	pass

Can you show your scene tree? Is your script attached to any node?

doesnt change anything :confused:

how do i do this? :open_mouth:

upload a screenshot of your “Scene” tab in the editor with your Node2D etc, maybe the bottom of your “Inspector” tab too.

1 Like

Super! looks in-order, what happens when you press F6 to run this scene? The screen will likely remain grey, but the output should say “5”

1 Like

yes, with f6 it does work. but why? :smiley:

Pressing run or F5 will run the “main scene” you can change the “main scene” in the project settings i think as “run scene”. this scene is not part of the “main scene”, you can instantiate this scene into the main scene via the chain icon in the Scene tab or ctrl+shift+a Probably like you have for “player” and “coin”

1 Like

okay, thanks alot!